SMTP Return-Path Setting

LUTi - May 21, 2008 - 10:36
Project:Mime Mail
Version:HEAD
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review
Description

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... ;-)

AttachmentSize
mimemail_smtp_return_path.patch1.79 KB

#1

Allie Micka - August 3, 2008 - 15:00
Status:active» won't fix

On the PHP documentation page for mail():

The additional_parameters parameter is disabled in safe_mode and the mail() function will expose a warning message and return FALSE when used.

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!

#2

gnosis - August 19, 2008 - 17:29

For 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.

AttachmentSize
mimemail_smtp_return_path_nospace.patch 1.83 KB

#3

LUTi - September 9, 2008 - 12:32

I 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:

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.

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.

#4

mfb - July 7, 2009 - 16:10
Status:won't fix» needs review

For 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.

AttachmentSize
envelope-sender.patch 2.53 KB

#5

yan - July 8, 2009 - 05:49

mfb: 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.

#6

mfb - July 8, 2009 - 06:37

@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.

#7

mrfelton - October 28, 2009 - 22:49

I 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:

/**
* Implementation of hook_mail_alter().
* Here we allow the site name to be used as the senders name for outgoing email.
* see http://drupal.org/node/209672
*/
function
mymodule_fast_mail_alter(&$message){
  $default_from = variable_get('site_mail', ini_get('sendmail_from'));

  if($message['from'] == $default_from){
    $message['from'] = '"'. variable_get('site_name', 'Drupal') .'" <'. $default_from .'>';
    $message['headers']['From'] = $message['headers']['Sender'] = $message['headers']['Return-Path'] = $message['headers']['Errors-To'] = $message['headers']['Reply-To'] = $message['from'];
  }
}

AttachmentSize
mimemail-envelope-sender-with-regex.patch 1.88 KB

#8

0bar - November 8, 2009 - 22:21

Hello mrfelton ,

Your solution works fine! I did something similar, (see http://drupal.org/node/338123 #5), but your solutions is nicer..

Thank you.

 
 

Drupal is a registered trademark of Dries Buytaert.