I was trying to add a custom header using the AWS PHP SDK so I can implement the "List-unsubscribe" header.
The problem is that I cannot find anywhere how to implement it.
I've read the documentation but nothing.
http://docs.aws.amazon.com/aws-sdk-php/v2/api/class-Aws.Ses.SesClient.html#_sendEmail
What am I doing wrong?
Thanks in advance for any help provided.
require_once("./AWS/aws-sdk/aws-autoloader.php");
$config = array('credentials' => array('key' => $awsKey,
'secret' => $awsSecret),
'version' => 'latest',
'region' => 'us-east-1');
$client = \Aws\Ses\SesClient::factory($config);
$to = 'test@example.com';
$from = 'testfrom@example.com';
$subject = 'This is a test';
$text= 'This is a test';
$html= 'This is a <b>test</b>';
$replyTo = 'replyto@example.com';
$message=array(
// Source is required
'Source' => $from,
// Destination is required
'Destination' => array('ToAddresses' => array($to)),
// Message is required
'Message' => array(
// Subject is required
'Subject' => array(
// Data is required
'Data' => $subject,
'Charset' => 'UTF-8',
),
// Body is required
'Body' => array(
'Text' => array(
// Data is required
'Data' => $text,
'Charset' => 'UTF-8',
),
'Html' => array(
// Data is required
'Data' => $html,
'Charset' => 'UTF-8',
),
),
),
// reply To..
'ReplyToAddresses' => array($replyTo),
// Is this correct??
'AddHeaderAction' => array('header_name'=> "List-Unsubscribe",
'header_value'=> urlencode('<unsubscribeme@example.com>')));
try
{
$result = $client->sendEmail($message);
$messageID=$result->get('MessageId');
}
catch (Exception $response)
{
die('error');
}
echo 'message sent: '. $messageID;