Skip to content
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

Message created (SingleTo) not putting recipient in To: header #1

Open
danwood opened this issue Jul 20, 2011 · 6 comments
Open

Message created (SingleTo) not putting recipient in To: header #1

danwood opened this issue Jul 20, 2011 · 6 comments

Comments

@danwood
Copy link

danwood commented Jul 20, 2011

See https://forums.aws.amazon.com/thread.jspa?messageID=262802&#262802 for a full background of the problem.

Essentially it seems like the 'SingleTo' field is not what I would expect it to be. When I create a message and send it (with SingleTo being on by default, the message header does not include the To: header. It seems like it ought to. And when I try forcing it off (maybe it does the opposite of what I expect it to?) then the message won't get sent at all.

Any ideas? Is this a bug, or am I misunderstanding things? How do I get a message sent via SES to include the To: header so that it properly shows up for the recipient?

@aaronpk
Copy link
Contributor

aaronpk commented Jul 25, 2011

Hi Dan,

I'm not sure about the issue you're having with SingleTo, but here is how I am using the code successfully:

<?php
        $mailer = new AmazonSESMailer(AWS_ACCESS_KEY_ID, AWS_SECRET_KEY);
        $mailer->SetFrom($from);
        $mailer->AddAddress($to);
        $mailer->Subject = $subject;
        $mailer->AltBody = $text;
        $mailer->MsgHTML($html);
        $mailer->Send();
?>

This results in emails with the following headers

Date: Sun, 24 Jul 2011 16:53:48 +0000
From: geonotes@geoloqi.com
Subject: You picked up a Geonote!
To: aaron@parecki.com

Hope this helps!

@danwood
Copy link
Author

danwood commented Jul 25, 2011

Weird ... OK, I dug some more and it appears that if I call your steps, the resulting email has a "To:" header in it. However, my messages (which don't follow quite the same code path) don't.

If I call CreateHeader() and print out the header right before sending it, the To: is missing. So it's really hard to diagnose. What's the logic for actually getting the To: header put onto the final header when the message is sent?

@mariusbutuc
Copy link
Contributor

@danwood, SingleTo serves another purpose:

/**
 * Provides the ability to have the TO field process individual
 * emails, instead of sending to entire TO addresses
 * @var bool
 */
 public $SingleTo      = true;

As @aaronpk suggested, AddAddress() is the way to go: Adds a "To" address.

@solkennedy
Copy link

I'm also experiencing this issue. As the linked forum page discusses, the 'Deliver-To' is being set, but 'To:' is not being set in the headers. This results in '(Undisclosed Recipients)' being in the To field of most email clients.

Setting $singleTo = false seems to not be supported at the moment either?

$mail = new AmazonSESMailer(SES_ID,SES_KEY);
$mail->SetFrom('info@domain.com','FromName');
$mail->AddAddress($to);
$mail->Subject = $subject;
$mail->Body = $body;
return (bool)$mail->Send();

@kalleboo
Copy link

I had the same problem. I solved it by editing AmazonSESMailer.php:55 from:

                'Data' => base64_encode($header . "\n" . $body)

to

                'Data' => base64_encode('To: '.$val."\n".$header . "\n" . $body)

@nasirsher
Copy link

thanks @kalleboo your idea worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants