[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 08-17-2006, 02:47 PM   #1 (permalink)
NamePros Regular
 
Tree's Avatar
 
Join Date: Feb 2006
Location: Atlanta, GA, USA
Posts: 335
13.25 NP$ (Donate)

Tree will become famous soon enoughTree will become famous soon enough


Regex Problem

I need to get a sender's email address, and currently I have this to get it:

PHP Code:
if (preg_match('/[fF]rom: ?[a-z0-9&\.\-_\+]+@[a-z0-9\-]+\.([a-z0-9\-]+\.)*?[a-z]{2,6}+/is', $lines[$i], $matches))
{
            
$from = $matches[1];
}
Any idea on why it's not getting the address? It will get the address if it's from anything but a cell phone, which is what I need it to get anyways.

An email header looks like this (Gmail to be specific)

Code:
X-Gmail-Received: 3e2a278a881c7984581aa1094b4d2113d72b66fb
Delivered-To: ***********@gmail.com
Received: by 10.65.22.17 with SMTP id z17cs117504qbi;
		Fri, 11 Aug 2006 09:33:39 -0700 (PDT)
Received: by 10.70.32.10 with SMTP id f10mr5373443wxf;
		Fri, 11 Aug 2006 09:33:39 -0700 (PDT)
Return-Path: <************@**********.com>
Received: from server1.*********.net (server1.***********.net [207.44.194.78])
		by mx.gmail.com with ESMTP id g5si2502179wra.2006.08.11.09.33.39;
		Fri, 11 Aug 2006 09:33:39 -0700 (PDT)
Received-SPF: neutral (gmail.com: 207.44.194.78 is neither permitted nor denied by best guess record for domain of *************@************.com)
Received: from adsl-**-**-***-***.dsl.chcgil.*********.net ([75.34.222.162] helo=********.com)
	by server1.compdetailhosting.net with esmtp (Exim 4.52)
	id 1GBZx4-0006Jy-Tt
	for ************@gmail.com; Fri, 11 Aug 2006 11:33:39 -0500
Subject: txtmorelogos
Date: Fri, 11 Aug 2006 11:29:40 -0500
MIME-Version: 1.0
Content-Type: multipart/mixed;
	boundary="----_=_NextPart_001_01C6BD63.FD9ED176"
Message-ID: <4229AB11C6B5D44FA48F7E619CA106199A34@server.*********.local>
X-MS-Has-Attach: yes
Content-class: urn:content-classes:message
X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0
X-MS-TNEF-Correlator: 
Thread-Topic: txtmorelogos
thread-index: Aca9Y1g65Qjva9ttQ1qzqIXJHNiPPQ==
From: "*** ******" <******@***********.com>
To: <********@gmail.com>
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - server1.***********.net
X-AntiAbuse: Original Domain - gmail.com
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - ***********.com
X-Source: 
X-Source-Args: 
X-Source-Dir:
Here's one from a cell phone

Code:
X-Gmail-Received: 73846296487d2bd716901530c4c94213d244f017
Delivered-To: ************@gmail.com
Received: by 10.65.22.17 with SMTP id z17cs129842qbi;
		Fri, 11 Aug 2006 19:16:51 -0700 (PDT)
Received: by 10.35.51.13 with SMTP id d13mr7473028pyk;
		Fri, 11 Aug 2006 19:16:51 -0700 (PDT)
Return-Path: <**********@messaging.sprintpcs.com>
Received: from lxnsmsexim01.nmcc.sprintspectrum.com ([68.28.214.143])
		by mx.gmail.com with ESMTP id m2si2929784nzf.2006.08.11.19.16.51;
		Fri, 11 Aug 2006 19:16:51 -0700 (PDT)
Received-SPF: neutral (gmail.com: 68.28.214.143 is neither permitted nor denied by best guess record for domain of **********@messaging.sprintpcs.com)
Received: from messaging.sprintpcs.com (unknown [10.25.157.71])
	by lxnsmsexim01.nmcc.sprintspectrum.com (Postfix) with SMTP id 02D5C10294B
	for <*******@gmail.com>; Fri, 11 Aug 2006 21:16:50 -0500 (CDT)
From:**********@messaging.sprintpcs.com
To:****************@gmail.com
Subject:
X-OPWV-Extra-Message-Type:MO
Message-Id: <20060812021650.02D5C10294B@lxnsmsexim01.nmcc.sprintspectrum.com>
Date: Fri, 11 Aug 2006 21:16:50 -0500 (CDT)
Everything was kept the same except for the asterisks which were added for privacy.

Last edited by Tree; 08-19-2006 at 02:16 PM.
Tree is offline  
Old 08-19-2006, 02:18 PM   #2 (permalink)
NamePros Regular
 
Tree's Avatar
 
Join Date: Feb 2006
Location: Atlanta, GA, USA
Posts: 335
13.25 NP$ (Donate)

Tree will become famous soon enoughTree will become famous soon enough


Anyone?
Tree is offline  
Old 08-19-2006, 02:40 PM   #3 (permalink)
NamePros Regular
 
Noobie's Avatar
 
Join Date: Feb 2006
Location: Montreal, Quebec, Canada
Posts: 324
66.75 NP$ (Donate)

Noobie is on a distinguished road


try using this guys regex

http://ca3.php.net/manual/en/ref.mail.php#66705

not sure if it functions as needed.
__________________
Goldkey.com is a scam
What's your BMI? | Timestamp Generator
Noobie is offline  
Old 08-19-2006, 07:19 PM   #4 (permalink)
NamePros Regular
 
Tree's Avatar
 
Join Date: Feb 2006
Location: Atlanta, GA, USA
Posts: 335
13.25 NP$ (Donate)

Tree will become famous soon enoughTree will become famous soon enough


That should work great. Thanks Noobie!

PHP Code:
 if ( preg_match("/From:.*?[A-Za-z0-9\._%-]+\@[A-Za-z0-9\._%-]+.*/", $headers, $froms) ) {
     
preg_match("/[A-Za-z0-9\._%-]+\@[A-Za-z0-9\._%-]+/", $froms[0], $fromarr);
     
$from = $fromarr[0];
  }
Tree is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 02:23 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85