我試圖通過使用PHP的AmazonSES發送帶有圖片附件的原始郵件。當我將電子郵件發送到Gmail帳戶但Hotmail帳戶正在接收空的附加圖像時,它效果很好。換句話說,hotmail似乎認識到有附件,這些附件具有我指定的正確名稱,只是它們總是空的,大小爲0字節。谷歌搜索沒有幫助...提前致謝!hotmail沒有收到圖片附件內容
$amazonSES = new AmazonSES();
// if (empty($attach)==0) {
// $response = $amazonSES->send_email(AWS_SES_FROM_EMAIL,
// array('ToAddresses' => array($to)),
// array('Subject.Data' => $subject,'Body.Text.Data' => $messagein,)
//);
// } else {
$rstring = 'ajfas90lsjhntlen89y34oi598';
$message= "To: ".$to."\n";
$message.= "From: " . AWS_SES_FROM_EMAIL . "\n";
$message.= "Subject: " . $subject . "\n";
$message.= "MIME-Version: 1.0\n";
$message.= 'Content-Type: multipart/mixed; boundary="ARandomString'.$rstring.'"';
$message.= "\n\n";
$message.= "--ARandomString$rstring\n";
$message.= 'Content-Type: text/plain; charset="utf-8"';
$message.= "\n";
$message.= "Content-Transfer-Encoding: 7bit\n";
$message.= "Content-Disposition: inline\n";
$message.= "\n";
$message.= $messagein;
$message.= "\n\n";
$message.= "--ARandomString$rstring\n";
foreach ($attach as $attachment) {
// $message.= "Content-ID: \<[email protected]_IS_ADDED\>\n";
$message.= "Content-ID: \<". md5(uniqid(rand(), true)) ."@biomechanico.com\>\n";
$message.= 'Content-Type: application/zip; name="shell.zip"';
$message.= "\n";
$message.= "Content-Transfer-Encoding: base64\n";
$message.= 'Content-Disposition: attachment; filename="' . $attachment["name"] . '"';
$message.= "\n" . base64_encode(file_get_contents($attachment["file"])) . "\n";
$message.= "--ARandomString$rstring\n";
}
$response = $amazonSES->send_raw_email(array(
'Data'=> base64_encode($message)),
array('Source'=>AWS_SES_FROM_EMAIL, 'Destinations'=> $to));
這些解決了我的問題,謝謝。我試圖使用PHPmailer,但無法弄清楚如何讓它與亞馬遜工作。再次感謝 – nbunderson
@nbunderson您可能需要調用類似於['getSentMIMEMessage'](http://phpmailer.github.io/PHPMailer/classes/PHPMailer.html#method_getSentMIMEMessage)的東西,並將結果字符串分配給'$ message'。 –