/    Sign up×
Community /Pin to ProfileBookmark

preg_split, preg_match, explode()??? Stumped

Hey All,

Trying to retrieve email address from bounced email in mysql table.

I have most of my bounced emails marking my contacts.email as invalid by
a removeme.id.tag in the sent email. But sometimes the mailer daemon just returns something like the following in the email body.

[QUOTE]

This is an automatically generated Dlevery Status Notification. Delivery To the following recipients failed. ‘[email protected]

[/QUOTE]

without the id.tag. So… how might I go about extracting the email address from the email body?

[code=php]while ($row = mysql_fetch_assoc($result))
{ //$row[‘description’] == email body text

$description = $row[‘description’];
$str = ‘This is an automatically generated Dlevery Status Notification. Delivery To the following recipients failed.’ ;
//$_split_email = preg_split (‘//’,’$str’, $description);
//$_split_email = array_shift(explode(‘$str’, $description));

$_split_email = array_pop(explode(‘$description’, $str,));

echo $_split_email;
}[/code]

Better Still… how might i just ignore all BUT the email string in the body, as the body text is bound to vary from one mailer_daemon to the next?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NightShift58Mar 29.2007 — None of the above.[code=php]<?php
$ignore_len = strlen('This is an automatically generated Dlevery Status Notification. Delivery To the following recipients failed.') + 1 ;
WHILE ($row = mysql_fetch_assoc($result)) :
$thisADDR = substr($row['description'],$ignore_len, -1)
echo $thisADDR;
ENDWHILE;
?>[/code]
The +1 and -1 are there to account for the single quotes wrapping the email address.
Copy linkTweet thisAlerts:
@MrCoderMar 29.2007 — [code=php]
<?php
while($row = mysql_fetch_assoc($result))
echo preg_replace("/.*?'(.*?)'.*/s", "$1", $row['description']);
?>
[/code]
×

Success!

Help @tjmcd spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...