-
Notifications
You must be signed in to change notification settings - Fork 24
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
Return-Path (Envelope From) should always be set to user's valid email #64
Comments
The benefit of this is that email bounces (wrong destination, ...) return to the individual user, NOT to the normal PHP return path which is something generic like www-data@localhost or whatever you set in httpd.conf via
|
One other important thing: in theory, we can achieve the same with IMAPMAIL, with two additional lines. The current logic (simply appending "'Return-Path: [email protected]" to $headers does not work, because imap_mail has a separate parameter for the return path as per http://php.net/manual/en/function.imap-mail.php !): $returnpath = $this->username;
[...]
$send = imap_mail ( $toaddr, $message->headers["subject"], $body, $headers, $ccaddr, $bccaddr, $returnpath); Unfortunately, this bug https://bugs.php.net/bug.php?id=30688 prevents this for now from working. My conclusion is that it only makes sense not NOT use IMAP_USE_IMAPMAIL (what's the benefit anyway), and as a result get a working, correct return-path/envelope-from. |
For me, i would deprecate IMAP_USE_IMAPMAIL, and only use mail... |
I have rewrite the SendMail function, and now it should work better. Also it supports mail (PHP), sendmail (system) and SMTP (PHP). |
define('IMAP_USE_IMAPMAIL', false); // In config.php |
Actually, this code does not work as expected: $envelopefrom = preg_replace('/^([^<]+)\s*<([^>]+)>\s*$/','-F "$1" -f "$2"',$message->headers["from"]);
$send = @mail ( $toaddr, $message->headers["subject"], $body, $headers, $envelopefrom ); because the variable $envelopefrom needs to look like this: "-f [email protected]" whereas the above code only generates "[email protected]": note the missing -f flag, which will in turn cause PHP mail() to ignore the specificed envelopefrom. So a simple fix is adding the "-f " prefix for the sendmail command in the second line at the end: $envelopefrom = preg_replace('/^([^<]+)\s*<([^>]+)>\s*$/','-F "$1" -f "$2"',$message->headers["from"]);
$send = @mail ( $toaddr, $message->headers["subject"], $body, $headers, " -f $envelopefrom" ); I just ran into this issue on a new installation, would it be possible to fix/close this really simple issue, please? |
It's interesting, I use the code above in more place, and it's working :) |
Well, for me it did not put the "-f" in front; I printed out $envelopefrom to the log and it was (at least in my case with Sogo ZEG) always an email address /without/ the leading "-f". |
The current logic in backend/imap.php does not guarantee that Return-Path (Envelope From) is always set to the user's valid email address.
Android devices can freely set the "From:" field (iOS only allows the user name!), and can sends values such as "User Name [email protected]" as "From", which according to the current code would result in a 5th parameter to PHP mail that looks like "-f User Name [email protected]" which is not accepted. The correct value for a return path would be "-f [email protected]".
In my case, I use email addresses as user names, so for me the following quick fix works, but somebody should think of how to get a valid email address from the above "From" value. It also requires that IMAP_USE_IMAPMAIL is set to FALSE, for now.
The text was updated successfully, but these errors were encountered: