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

BCC parsing failure #57

Closed
vSaKv opened this issue May 25, 2015 · 7 comments
Closed

BCC parsing failure #57

vSaKv opened this issue May 25, 2015 · 7 comments

Comments

@vSaKv
Copy link

vSaKv commented May 25, 2015

Hi,
first of all thanks a lot for the great plugin. It works for most emails, but recently I noticed issue with parsing when email send using BCC field. In this case TO: email header contains: undisclosed recipient; which causing error. Header example with BCC:
From: Test <test@yahoo.com> Reply-To: Test <test@yahoo.com> To: Undisclosed Recipients <test@yahoo.com> Message-ID: <269861739.294826.1432412463408.JavaMail.yahoo@mail.yahoo.com>
I was able to find recipient email addresses in Received from part (for <recipient@gmail.com>), but this part of the headers apparently ignored.

Return-Path: <test@yahoo.com>Received: from nm41-vm6.bullet.mail.gq1.yahoo.com (nm41-vm6.bullet.mail.gq1.yahoo.com. [67.195.87.93]) by mx.google.com with ESMTPS id cg8si9129786pac.134.2015.05.23.13.24.04 for <recipient@gmail.com> (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 23 May 2015 13:24:05 -0700 (PDT) Received-SPF: pass (google.com: domain of test@yahoo.com designates 67.195.87.93 as permitted sender) client-ip=67.195.87.93;

Thank you

@megaroma
Copy link

When this feature is gonna be added?

@eXorus
Copy link
Member

eXorus commented Mar 20, 2016

Hi,

I try a raw email with :
To: Undisclosed Recipients

And I don't have any error when I call $Parser->getHeader('to') the result is what I expect :
Undisclosed Recipients

After I don't understand you said that you are able to find the recipient email adress in Received Part but you can't parse it... so how to you retrieve it ?
All the headers can be retrieve by getHeader function there is no limitation.

@vSaKv
Copy link
Author

vSaKv commented Mar 20, 2016

Hi eXorus,
I manage to make it working while ago, I believe what is megaspy is asking, is when email sent with undisclosed recipient in To field, will be able to parse in a way, that he will be able to extract recipient emails address in order to deliver email. Atm when you use email parser you have parsed headers fields like: To, From, CC, etc. But when email is sent as BCC or actually even forwarded from another address, craigslist or other services, mailparse simply ignores final recipient, because in this case field To provides meaningless information

@CryDeTaan
Copy link

This should not be an enhancement as the functionality is already there.

I am using the Mailcare Laravel web app as an example here, but it can be applied to any php scenario.

Looking at the The Postfix pipe(8) daemon you will notice that the last last command attribute is what is executed.
Using mailcare's ReceiveEmail command as an example we configure Postfix hook in master.cf to execute the mailcare:email-receive artisan command as follow:

smtp inet n - - - - smtpd -o content_filter=mailcare:dummy
mailcare unix - n n - - pipe flags=F user=forge argv=php /home/forge/example.org/artisan mailcare:email-receive

Now, going back to the pipe daemon, you will noticed as well, that we can specify command arguments, and some ${arguments} can be passed by postfix itself to the command.

Specifically looking at the ${recipient} argument we notice it would actually work better to determine the recipient, rather than using headers , because the ${recipient} passed by Postfix contains the actual address in the SMTP RCPT TO command which is what we want; headers can be spoofed.

So to solve the problem of getting all address in our Laravel Console command, we will not be using the Headers to determine the recipients but rather passing them by using Postfix the ${recipient} as a command argument which we can then get access to use/process further in the Artisan command.

  1. Update the hook in master.cf to include ${recipient} argument
mailcare unix - n n - - pipe flags=F user=forge argv=php /home/forge/example.org/artisan mailcare:email-receive ${recipient}
  1. Update our Mailcare ReceiveEmail Command's signature to expect the argument.
/**
  * The name and signature of the console command.
  *
  * @var string
 */
 protected $signature = 'mailcare:email-receive {recipients*}';
  1. Access the $recipients as an array within the command. Probably replacing the $file argument
 $recipients = $this->argument('recipients');
 foreach ($recipients as $recipients){
           // Code here
  }

For more information on how to make use of the arguments in the Artisan command, please take a look at the following sections in the Laravel Documentation, I found these very helpful:

@eXorus
Copy link
Member

eXorus commented May 13, 2020

I'm closing the issue because the explanation of @CryDeTaan is perfect.

In a nutshell: You should get recipient from the mail server instead of the headers of the emails.

@eXorus eXorus closed this as completed May 13, 2020
@vSaKv
Copy link
Author

vSaKv commented Dec 3, 2021

Sorry to jump so late, but I disagree with the mail server part. We are talking about email parser, the script should be functioning(correctly parsing an email) without relying on third-party services like postfix or etc. I.e email body should be sufficient to provide all necessary information, let say we have to parse an email log.

@eXorus
Copy link
Member

eXorus commented Dec 7, 2021

Agree with you but could you give the full email example.
Because the parser already provides all the information we have in the email.
If the information doesn't exist I can't do anything.

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

No branches or pull requests

4 participants