Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get from email address #7

Open
tmajczak opened this issue Jul 4, 2012 · 4 comments
Open

get from email address #7

tmajczak opened this issue Jul 4, 2012 · 4 comments

Comments

@tmajczak
Copy link

tmajczak commented Jul 4, 2012

No description provided.

@plancake
Copy link
Collaborator

plancake commented Jul 5, 2012

Hi.

Have you tried:
$emailParser->getHeader('From');
?

@tmajczak
Copy link
Author

tmajczak commented Jul 5, 2012

Yes, but it return all header and I must write preg_match to get
email_address :)

peace

2012/7/5 Plancake <
[email protected]

Hi.

Have you tried:
$emailParser->getHeader('From');
?


Reply to this email directly or view it on GitHub:

#7 (comment)

@behzadev
Copy link

For getting the From:

1- add this to the class:
public function getFrom()
{
if ( (!isset($this->rawFields['from'])) || (!count($this->rawFields['from'])))
{
throw new Exception("Couldn't find the FROM");
}
return explode(',', $this->rawFields['from']);
}

2- define this function:
function extract_email_address ($string) {
foreach(preg_split('/ /', $string) as $token) {
$email = filter_var(filter_var($token, FILTER_SANITIZE_EMAIL), FILTER_VALIDATE_EMAIL);
if ($email !== false) {
$emails = $email;
}
}
return $emails;
}

now:
$from = ($emailFrom = $emailParser->getFrom());
echo "From --> " . extract_email_address($from[0]);

@tolgamorf
Copy link

I also needed this functionality and tried to implement it myself. See my commit: 1b94069

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants