這裏是我如何做到這一點,而不SDK:
<?php
error_reporting(E_ALL);
ini_set('display_errors','On');
// AMAZON PARAMETERS
$sAccess = 'YOUR-ACCESS-KEY-GOES-HERE';
$sSecret = 'YOUR-SECRET-KEY-GOES-HERE';
$sURL = 'https://email.us-east-1.amazonaws.com/'; // may be subject to change!
$nVerifyHost = 1; // may need to set either of these to 0 on some hosting plans
$nVerifyPeer = 1;
// OUR TEST MESSAGE
$sTo = '[email protected]'; // must request production mode in AWS SES Console
$sFrom = '[email protected]'; // must verify the sender in the AWS SES Console
$sSubject = 'Hello, World!';
$sMessage = <<<EOD
<p>This is para 1.</p>
<p>This is para 2.</p>
<p>Regards,<br>
<b>Management</b></p>
EOD;
// SEND THE MESSAGE
$sDate = gmdate('D, d M Y H:i:s e');
$sSig = base64_encode(hash_hmac('sha256', $sDate, $sSecret, TRUE));
$asHeaders = array();
$asHeaders[] = 'Date: ' . $sDate;
$asHeaders[] = 'X-Amzn-Authorization: AWS3-HTTPS AWSAccessKeyId=' . $sAccess .
',Algorithm=HmacSHA256,Signature=' . $sSig;
$asHeaders[] = 'Content-Type: application/x-www-form-urlencoded';
$sText = $sMessage;
$sText = str_replace("\r\n",'',$sText);
$sText = str_replace("\r",'',$sText);
$sText = str_replace("\n",'',$sText);
$sText = str_replace("\t",' ',$sText);
$sText = str_replace('<BR />','<br />',$sText);
$sText = str_replace('<BR/>','<br />',$sText);
$sText = str_replace('<BR>','<br />',$sText);
$sText = str_replace('</P>','</p>',$sText);
$sText = str_replace('</p>',"</p>\n\n",$sText);
$sText = str_replace('<br />',"<br />\n",$sText);
$sText = strip_tags($sText);
$asQuery = array(
'Action' => 'SendEmail',
'Destination.ToAddresses.member.1' => $sTo,
'Source' => $sFrom,
'Message.Subject.Data' => $sSubject,
'Message.Body.Text.Data' => $sText,
'Message.Body.Html.Data' => $sMessage
);
$sQuery = http_build_query($asQuery);
$hCurl = curl_init();
curl_setopt($hCurl, CURLOPT_SSL_VERIFYHOST, $nVerifyHost);
curl_setopt($hCurl, CURLOPT_SSL_VERIFYPEER, $nVerifyPeer);
curl_setopt($hCurl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($hCurl, CURLOPT_POSTFIELDS, $sQuery);
curl_setopt($hCurl, CURLOPT_HTTPHEADER, $asHeaders);
curl_setopt($hCurl, CURLOPT_HEADER, 0);
curl_setopt($hCurl, CURLOPT_URL, $sURL);
curl_setopt($hCurl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($hCurl, CURLOPT_FOLLOWLOCATION, 1);
$asResult = array('code'=>'','error'=>'');
if (curl_exec($hCurl)) {
$asResult['code'] = curl_getinfo($hCurl, CURLINFO_HTTP_CODE);
} else {
$asResult['error'] = array (
'code' => curl_errno($hCurl),
'message' => curl_error($hCurl),
);
}
@curl_close($hCurl);
print_r($asResult);
雖然你應該得到一個真正的錯誤,你有沒有驗證* *兩者的收件人和發件人地址發送?在開發人員沙箱中時,您需要這樣做。此外,SES是超新的,我認爲他們上週推出了SDK的新副本,因此值得檢查...... – Charles 2011-03-21 03:38:45
如何驗證電子郵件地址?我添加了$ ses-> verify_email_address的調用,但沒有任何更改。 ubuntu @ localhost是我在本地ubuntu實例上運行的用戶。 – Simian 2011-03-21 03:42:12
它必須是SES可以發送到的可公開訪問的電子郵件地址。 – 2011-03-27 04:38:32