所以我遇到SendRawEmail (Amazon SES)的问题,电子邮件已发送但未送达! 这是我的代码:
$phpMail = new PHPMailer();
$phpMail->addAddress($this->getToEmail(), $this->getToName());
$phpMail->setFrom($this->getFromEmail(), $this->getFromName());
$replyTo = $this->getReplyTo();
if($replyTo){
$phpMail->addReplyTo($this->getReplyToEmail(), $this->getReplyToName());
}
$phpMail->Subject = $subject;
$phpMail->CharSet = 'UTF-8';
$phpMail->AltBody = $plainBody;
$phpMail->Body = $htmlBody;
// $mail->isHTML(true);
$phpMail->preSend();
$rawEmail = array(
'Source' => $this->getFromEmail(),
'Destinations' => array($this->getToEmail()),
'RawMessage' => array(
'Data' => base64_encode($phpMail->getSentMIMEMessage())
)
);
$mail = $this->getSender();
$command = $mail->getCommand("SendRawEmail", $rawEmail);
/** @var Aws\Result $result */
$result = $mail->execute($command);
此结果返回状态200
{ "MessageId": "someid",
"@metadata": {
"statusCode": 200,
"effectiveUri": "https:\/\/email.us-east-1.amazonaws.com",
"headers": { "x-amzn-requestid": "somegenerated id",
"content-type": "text\/xml",
"content-length": "338",
"date": "Tue, 11 Aug 2015 07:33:03 GMT" }
但是,如果我发送电子邮件与SendEmail交付
$mail = $this->getSender();
$message = array();
$message['Source'] = "{$this->getFromName()} <{$this->getFromEmail()}>";
$message['Destination']['ToAddresses'][] = "{$this->getToName()} <{$this->getToEmail()}>";
$message['Message'] = array(
'Subject' => array(
'Data' => $this->getSubject()
),
'Body' => array(
'Text' => array('Data' => $this->getBodyPlain()),
'Html' => array('Data' => $this->getBodyHtml())
)
);
$replyTo = $this->getReplyTo();
if($replyTo){
$message['ReplyToAddresses'] = $replyTo;
}
try {
$command = $mail->getCommand("SendEmail", $message);
/** @var Aws\Result $result */
$result = $mail->execute($command);
我需要通过SendRawEmail发信,因为我需要设置自定义标题,但是如何调试我的问题,任何建议?
答案 0 :(得分:1)
所以我发现了一个错误 我需要发送没有base64_encode的电子邮件,因为我没有附件