Skip to content

Instantly share code, notes, and snippets.

@meglio
Created March 21, 2011 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meglio/880059 to your computer and use it in GitHub Desktop.
Save meglio/880059 to your computer and use it in GitHub Desktop.
Finds email / name in specific email provided by Segovia, and replaced FROM value with these values
<?php
define('FILE_IN', 'in.txt');
define('FILE_OUT', 'out.txt');
$original = file_get_contents(FILE_IN);
$res = preg_match('/Your Full Name:[^a-z]*(?P<fullName>[a-z ]+)[^a-z]*Email:[^a-z]*(?P<email>[1-9a-z@ \.]+)/is', $original, $matches);
if (!$res) exit;
$fullName = trim($matches['fullName']);
$email = trim($matches['email']);
$replaced = str_replace(
'From: Form Processor <forms@formexperts.com (mailto:forms@formexperts.com)>',
"From: $fullName <$email (mailto:$email)>",
$original);
file_put_contents(FILE_OUT, $replaced);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment