Jump to content

Recommended Posts

I am trying to process an incoming email.  I am using the code below.  I want to use the $from to seach a database, however the $from is just providing a name, rather than the email address.  Can anyone help me find the full email address?

 

$fd = fopen("php://stdin", "r");
// Do whatever must be done
$email = "";
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);

// handle email
$lines = explode("\n", $email);
// empty vars
$from = "";
$subject = "";
$headers = "";
$message = "";
$splittingheaders = true;

for ($i=0; $i<count($lines); $i++) 
{
if ($splittingheaders) 
{
	// this is a header
	$headers .= $lines[$i]."\n";
	// look out for special headers
	if (preg_match("/^Subject: (.*)/", $lines[$i], $matches)) 
	{
	$subject = $matches[1];
	}
	if (preg_match("/^From: (.*)/", $lines[$i], $matches)) 
	{
	$from = $matches[1];
	}
} 
else 
	{
	// not a header, but message
	$message .= $lines[$i]."\n";
	}
	if (trim($lines[$i])=="") 
	{
	// empty line, header section has ended
	$splittingheaders = false;
	}
}

 

Many thanks

 

Stuart

Link to comment
https://forums.phpfreaks.com/topic/162043-solved-incoming-email-address/
Share on other sites

From me@stuartseeley.com Sat Jun 13 12:10:00 2009 Received: from localhost ([127.0.0.1] helo=diamond.speednoc.com) by diamond.speednoc.com with smtp (Exim 4.69) (envelope-from ) id 1MFWjw-0001P4-PE for testemail@1083squadron.co.uk; Sat, 13 Jun 2009 12:10:00 -0500 Received: from CAS01.apps4rent.com ([198.77.13.241] helo=CAS01.apps4rent.com) with IPv4:25 by diamond.speednoc.com; 13 Jun 2009 12:10:00 -0500 Received: from EXMBX01.apps4rent.net ([192.168.168.218]) by cas01.apps4rent.net ([192.168.168.241]) with mapi; Sat, 13 Jun 2009 10:09:57 -0700 From: Stuart Seeley To: "testemail@1083squadron.co.uk" Date: Sat, 13 Jun 2009 10:09:56 -0700 Subject: Leave Thread-Topic: Leave Thread-Index: AQHJ7EnGQW5eznLCw0yh7rPvuTRnNQ== Message-ID: <3B6DD99EBCA05E48A2042D7960A54C7A04DB13FFCE@EXMBX01.apps4rent.net> Accept-Language: en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: multipart/alternative; boundary="_000_3B6DD99EBCA05E48A2042D7960A54C7A04DB13FFCEEXMBX01apps4r_" MIME-Version: 1.0 X-Assp-Delay: testemail@1083squadron.co.uk not delayed (auto accepted); 13 Jun 2009 12:10:00 -0500 X-Assp-Score: 8 (No Spoofing Allowed 'me@stuartseeley.com') X-Assp-Received-SPF: softfail (cache) ip=198.77.13.241 mailfrom=me@stuartseeley.com helo=CAS01.apps4rent.com X-Assp-Score: 3 (SPF softfail) X-Assp-Envelope-From: me@stuartseeley.com

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.