Amazon SES now supports non-verified addresses in Reply-To headers. See the official documentation, http://docs.amazonwebservices.com/ses/latest/APIReference/ and the AWS developer forums thread, https://forums.aws.amazon.com/thread.jspa?threadID=60093&tstart=0 .

However, the Return-Path header must still use a verified address.

amazon_ses.mail.inc uses the 'Reply-To' header in a message to set the Return-Path in the function amazon_ses_send_messageg():

    $opt['ReturnPath'] = $source;
    if (isset($message['headers']['Reply-To']) && !empty($message['headers']['Reply-To'])) {
      if (strpos($message['headers']['Reply-To'], '<')) {
        $opt['ReturnPath'] = preg_replace('/>.*/', '', preg_replace('/.*</', '', $message['headers']['Reply-To']));
      }
      else {
        $opt['ReturnPath'] = $message['headers']['Reply-To'];
      }
    }

So if you are setting an arbitrary, non-verified Reply-To address, the messages will fail, with an incorrect watchdog error that the 'From' address is not verified.

I created this patch to properly add the Reply-To headers to the SES message. In the function amazon_ses_send_message() :

    $opt['ReturnPath'] = $source;

    // Reply-to headers
    if (isset($message['headers']['Reply-To']) && !empty($message['headers']['Reply-To'])) {
      $reply_to_members = split(",", $message['headers']['Reply-To']);
      $n = 1;
      foreach ($reply_to_members as $member) {
        if (strpos($member, '<')) {
          $opt['ReplyToAddresses.member.' . $n] = preg_replace('/>.*/', '', preg_replace('/.*</', '', $member));
        }
        else {
         $opt['ReplyToAddresses.member.' . $n] = $member;
        }
        $n++;
      }
    }

I am attaching a patch also, I am not sure I did it correctly. I am sure the code could be better, but this worked.

This appears to be a problem in the amazon_ses-7.x-1.0-beta2.zip release also, but I don't have a system to test on.

I'm sorry I don't know enough about SES to hunt down putting the correct error message into watchdog.

Comments

calebtr’s picture

whoops, called split() instead of explode()

geerlingguy’s picture

Subscribe.

mark trapp’s picture

Version: 6.x-1.0-beta2 » 7.x-1.0-beta2
Status: Active » Needs review
StatusFileSize
new1.39 KB

Patch wasn't applying, so I re-rolled it, cleaned up a couple of coding standards issues, and replaced split() with explode() to fix the E_DEPRECATED issue.

This is a problem in all versions, so it should probably go into the latest version and be backported to 6.x.

thebuckst0p’s picture

Before I saw this, I posted a semi-duplicate patch for this and the From Name bug at http://drupal.org/node/1133912#comment-4780196

r.aubin’s picture

It appears that this problem causes a conflict with the Forward module http://drupal.org/project/forward (6.x version) because Forward sets the Reply-To to the user sending the email, not Drupal's sending address. If anyone has already created a version of this patch for 6.x, please post.

r.aubin’s picture

StatusFileSize
new991 bytes

Here is a patch for the amazon_ses.mail.inc file which corrects the Reply-To problem in this thread. This patch is for the 6.x version of the Amazon SES module.

tkuldeep17’s picture

Status: Needs review » Closed (won't fix)

This version is not supported now.