0

I've set up Amazon SES on my server. I'm using AWS SDK for PHP. It's version one. Here's the documentation. Here is the code I'm using to send:

$to = $_POST['mailto']; 

$response = $email->send_email(
  $from, // Source (SENDER or FROM)
  array('ToAddresses' => array( // Destination (RECIPIENT, or TO)
      $to
  )),

In the AWSSDK docs, here is their example for sending emails to one person:

$response = $email->send_email(
    'no-reply@amazon.com', // Source (aka From)
    array('ToAddresses' => array( // Destination (aka To)
        'nobody@amazon.com'
    )),

And to multiple people:

$response = $email->send_email(
    'no-reply@amazon.com', // Source (aka From)
    array( // Destination (aka To)
        'ToAddresses' => array(
            'nobody@amazon.com',
            'nobody@amazon.com'
        )),

I can send to one person easily enough, but no matter what I do, I can't send to two people. I've tried making the recipients 'one@email.com', 'two@email.com', or one@email.com,two@email.com, but it doesn't work. I need the recipients to be in PHP on the page that has the form, so I can't hard code it into the sending PHP file.

It looks something like this.

<input type="hidden" value="one@email.com,two@email.com" id="mailto" name="mailto">

Any help you can give towards a solution would be greatly appreciated!

And I'm out of the Sandbox with production emails enabled.

If I do directly edit the send file, it will send.

Tania Rascia
  • 101
  • 4

1 Answers1

0

My solution:

// Get the string of recipients
$recipientString = $_POST['mailto'];

// Convert string to an array
$to = explode(',', $recipientString);

$from, // Source (SENDER or FROM)
array('ToAddresses' =>
   $to
),
Tania Rascia
  • 101
  • 4