Some mailers (I've had this issue with qmail in the past) request SMTP Return-Path parameter to be explicitely passed through -f parameter, otherwise they refuse to handle messages. That's when I've had to do a quick and dirty solution for my problem.
Now, I am using postfix (and, miss qmail sometimes a lot...), which doesn't complicate that much, but throws into the message header a Return-Path paramater "" instead of "", which would probably be much more normal to the recipients, and enable possible error messages to reach the webmaster...
To resolve the issues above, I've introduced another variable "smtp_return_path" admin can use; it can be empty (in this case, NULL is passed to mail() as an optional parameter), or any arbitrary e-mail address can be specified (I use webmasters address - in this case, "-f webmaster@my-web-server" string is passed as an optional parameter to the mail() function call).
My patch is in attachment. In case of an empty "SMTP Return-Path address" field, nothing shall be changed in functionality. I would be very happy if this can be adapted and I wouldn't have to patch all of the future versions to get the desired functionality... ;-)
| Comment | File | Size | Author |
|---|---|---|---|
| #27 | mimemail_261028_07.patch | 2.36 KB | sgabe |
| #26 | mimemail_261028_06.patch | 2.34 KB | sgabe |
| #22 | smtp_return_path_fix.6.x-0.2-alpha.tar_.gz | 3.05 KB | luti |
| #20 | mimemail.return_path.patch | 672 bytes | eaajithe |
| #13 | mimemail.261028_04.patch | 2.06 KB | sgabe |
Comments
Comment #1
allie mickaOn the PHP documentation page for mail():
This means that applying your patch will render mimemail inoperable for anyone running safe_mode. That would be bad :).
By setting Return-Path and Errors-To headers, mimemail can convince most MTA's to set the correct envelope sender for your messages. In cases where this won't work, you would be better off using the SMTP Authentication module as a mimemail backend, which covers more bases.
Thanks!
Comment #2
gnosis commentedFor anyone who does decide to use this patch, there is a little bug in it that caused me a bunch o' gray hair (http://drupal.org/node/297048). There should not be a space after the -f option. Here's an updated patch without the space.
Comment #3
luti commentedI agree with #1 statement, but isn't it possible to find a solution where it would be possible to set SMTP Return-Path parameter in an acceptable way? I mean, I urgently need it, as I was not able to convince my qmail to accept the message without.
Or, can you explain a bit better this, Allie, please:
Maybe I can resolve my problem this way, but I need to know what to change and where to achieve that.
About #2: my patch works for me without a problem, but as message is accepted also with this option without a space, your patch is better, I agree.
Comment #4
mfbFor my application I need to be able to set various envelope sender addresses for various types of outgoing messages, for correct bounce handling among other reasons. The attached patch adds an advanced option for setting the envelope sender address, and it will not cause the problem Allie noted at #1, as it checks the safe_mode ini setting before calling mail() with the $additional_parameters.
Comment #5
yan commentedmfb: Isn't that a different issue?
Has the return path problem of this module still not been solved? I'm having the same issue: When the mime mail module is enabled and used, the Return Path module doesn't have any effect and the return path is set wrong.
Comment #6
mfb@yan: I'm glad you brought this up, as I was recently looking at the Return Path module and noticing that it doesn't work with Mimemail. Perhaps another way to resolve this issue would be to patch the Return Path module to function as a backend for Mimemail? I haven't yet had a chance to look into this.
Comment #7
mrfelton commentedI too found the returnpath module, and realised it doesn't work with mimemail. I need this functionality. My version of the patch also allows for the sender name to be in the format
"Site Name" <user@example.com>, which I enable in a custom module like so:Comment #8
Robert Molenaar commentedHello mrfelton ,
Your solution works fine! I did something similar, (see http://drupal.org/node/338123 #5), but your solutions is nicer..
Thank you.
Comment #9
sgabe commentedPatch doesn't work with
safe_mode.We have to check the
safe_modefirst and we shall pass the additional parameter to themail()function according to the result.I am attaching a revised patch of #7.
Comment #10
sgabe commentedSorry, in my patch the
ifstatement is wrong. I attached the good one, please use this.Comment #11
drupalfan2 commentedPatch #10 does NOT work with mimemail + simplenews: Every time a message is sent with simplenews, error log shows that the message has not(!) been sent successfully.
Patch #4 works fine.
When will a fine working version of this patches be applied to mimemail?
Comment #12
sgabe commented@DrupalFan2: Please, read the documentation about issue status settings.
Comment #13
sgabe commentedI am attaching a new patch against current HEAD with Return-Path handling retrieved from Drupal 7.
Comment #14
Riggs333 commentedThanks sgabe!
The patch mimemail.261028_04.patch (#13) seems to work for me with drupal 6.19.
Comment #15
marcvangendsgabe: regarding the patch in #13, why do you check if the return path has already been set in the server configuration (
$return_path_set = strpos(ini_get('sendmail_path'), ' -f');)?I just had to apply your patch in a shared hosting environment where the sendmail_path by default contained a return path (set in the VirtualHost directive in httpd.conf) that I didn't want to use, causing the patch to do nothing. I changed the patch so the return-path is always set by the script, regardless of the php configuration:
Do you have a use case where the -f option of the send_path value of the php configuration must have preference over the return-path value set by the Drupal module?
Comment #16
sgabe commented@marcvangend: The patch is retrieved from D7, it's original issue is #131737: Ensure that the Return-Path is set when sending mail on both Windows and non-Windows systems.. I guess if the -f parameter has already been set in php.ini and we don't check that, it results in sendmail being called with two '-f' parameters, which is not so good. However I think you should share your opinion and ask your questions in the original issue.
Comment #17
lubnax commentedsubscribing
Comment #18
burlap commentedIt doesn't work for me. It seems that sendmail -f doesn't accept
<mail@example.com>(resulting in no mail being sent at all) format, but it'll work withmail@example.com.My quick and dirty hack (line 145 of mimemail.module):
Also, it seems that I don't need this patch at all, I get the Return-path without the -f option anyway.
Comment #20
eaajithe commentedFollowing works for me. I needed to get bounces to the email I set as "From"
I applied the attached patch to mimemail-6.x-1.0-alpha8 version.
It works great.
Comment #21
sgabe commentedWorks for you but will throw an error for anybody who uses safe mode. You should reroll and test the patch in #13.
Comment #22
luti commentedTo avoid patching mimemail (for the reson above, as well as to make my life easier - simply updating mimemail from time to time, without a need to recheck everything, and patch new version again and again...), I've created some time ago a separate module to fix this issue. Here it is, if anyone wants to give it a try.
Any feedback is of course more than welcome. ;-)
Comment #23
earth1 commentedAfter I sent a newsletter this came up. SMTP Error: Could not connect to SMTP host.. I did not get an email.
What shall I do?
Any help would be much appreciated.
Comment #24
luti commented@earth1,
as first, it would be good to describe more in detail what your environment is (Win$, linux, which mail server you have, can you send mails through it otherwise etc.), and how the mail system is supposed to work (what are your php.ini settings).
I guess you have a more general problem at the moment, not what this issue is about...
Comment #25
agence web coheractio commentedsubscribing
Comment #26
sgabe commentedI am attaching a new revised patch against the current development snapshot.
Comment #27
sgabe commentedNew patch on the basis of #18.
Comment #28
sgabe commentedCommitted to the development snapshot.
Comment #29
earth1 commented@LUTi
My environment is linux. Mime Mail sent the email through email engine drupal_mail() and the email was OK. SMTP is the issue. I don't know where the php.ini settings? Do you have any suggestion or do you have more questions?
Comment #30
sgabe commentedThen you should try in the SMTP issue queue.
Comment #31
luti commented@earth1,
php.ini is most probably in /etc (as mainly all other settings in linux). Do you manage this linux server by yourself? ;-)
And, how can the email be OK, when SMTP doesn't work? I'm not sure I understand exactly your issue...
Try to see the log files (usually in /var/logs), if you can be more precise about what exactly the problem is (logged errors and warnings). When you know exactly what you have to fix, it is usually very simple to resolve it nowadays (google & co.).
Comment #33
frederickjhI know that this issues is closed.
I just wanted to say thanks to @LUTi for sharing the custom module. Save the day for me. I moved to new hosting where I could not use a setting in a custom php.ini.
Your custom module works great!
Thanks and God Bless!
Frederick