Set correct Return-Path

batje - August 6, 2009 - 18:16
Project:Messaging
Version:6.x-2.2
Component:PHPMailer
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

The Return-Path is not set. The result of this, is that when using the "Full user data (User name and available user information)" option, all bounce messages (out of office, full mailbox etc.) go to the Drupal User who generated the notification.

Funny enough, elsewhere (in the messaging_mail_headers function) the correct headers are created, like:

    $more_headers['Sender'] = $more_headers['Return-Path'] = $more_headers['Errors-To'] = $default_from;

Adding the following lines of code to the messaging_phpmailer_drupal_mail function, solves this.

  if(!empty($message['headers']['Sender'])) {
    $mail->Sender = $message['headers']['Sender'];
  }
  if(!empty($message['headers']['Errors-To'])) {
    $mail->AddCustomHeader($message['headers']['Errors-To']);
  }

(PHPMailer creates the Return-path header from the Sender.)

#1

Dane Powell - August 6, 2009 - 21:59

I can't speak to the efficacy of this patch. It occurs to me though that we may not want replies to go to the site address, since there's a good chance that it's simply a "dummy" unmonitored account...

#2

batje - August 7, 2009 - 07:10

On mailinglists, the return-path is mostly used exactly for this. It will prevent all errors & out-of office messages to go to the person who just posted a blog, or a forum-post or anything else that people have subscribed to. The Reply-To field is used by email clients to send the real reply to.

In our scenario, we use mail2web & og & og_forum to mimic mailinglists. Drupal sets the FROM address to the users email, mail2web sets the Reply-To address to replies@example.com, and this code only fills in the Return-Path & Error-To to the site-email. All bounces end up in the site-email, all replies go to replies@example.com.

(I did not test without mail2web, but from reading the code, i think the FROM will still be the Drupal Users Email address)

A solution for the 'no read of replies' would be to make Return-Path & Errors-To configurable.

(and once we have that, we could think about proper bounce-handling, where all 'Mailbox does not exist' users would be disabled, etc. As the whole mailer-issue seems to be overhauled in Drupal 7, we might want to wait with this, though.)

#3

batje - August 7, 2009 - 07:13

Ah, and on a second note, this patch (the second part of code) does not set the Return-Path. It only sets the Return-Path to the value that is provided.

this code (that sets it):

$more_headers['Sender'] = $more_headers['Return-Path'] = $more_headers['Errors-To'] = $default_from;

is already in the module. Changing this, is another patch.

#4

Dane Powell - November 10, 2009 - 04:45

I agree that this should be implemented. I would like to let admins select the Return-Path and Errors-To addresses that they want to use for Messaging. I will take a look at ways of implementing this. As you point out, this might require some deeper changes than just to PHPMailer.

#5

Dane Powell - November 11, 2009 - 04:33
Status:active» needs review

Okay, try out this patch against 6.x-2.1. Note that if you've installed some other similar recent patches (allowing for BCC sending and custom from headers) that share features with this patch, you may have to apply it manually.

AttachmentSize
messaging-542022-5.patch 3.53 KB

#6

Dane Powell - November 11, 2009 - 23:45

Whoops, there was a problem with that patch that I didn't notice due to my restricted testing environment. This one should work.

AttachmentSize
messaging-542022-6.patch 3.52 KB

#7

Dane Powell - November 20, 2009 - 15:19
Version:6.x-2.1» 6.x-2.2

Very minor change to fix formatting (thanks, Coder module :) )

AttachmentSize
messaging-542022-7.patch 3.52 KB
 
 

Drupal is a registered trademark of Dries Buytaert.