PHPMailer和SES的困难

时间:2015-10-05 00:18:50

标签: amazon-web-services

我将网站从传统托管服务提供商转移到亚马逊。我似乎无法让邮件工作。

我确实通过SES获得了经过验证的电子邮件地址。

我看到sendmail正在运行。

我看到很多人都在努力解决这个问题。我的代码如下。

当我查看调试器窗口时,我收到了HTTP 500 Server错误。

无法加载资源:服务器响应状态为500(内部服务器错误)

<?php
ini_set('display_errors','on');
error_reporting(E_ALL);
require_once('class.phpmailer.php');
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP(); // telling the class to use SMTP
try{
$body = "Hello, \n This is just a test mail";
$mail->Host = "email-smtp.us-east-1.amazonaws.com"; // SMTP server of Amazon SES
$mail->Port = 587; // SMTP port of the Amazon SES
$mail->Username = "xxxxxxxx"; // SMTP username (Amazon SES Credentials)
$mail->Password = "xxxxxxxx"; // SMTP password (Amazon SES Credentials)
$mail->SMTPDebug = 0; // 1 to enables SMTP debug (for testing), 0 to disable debug (for production)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "tls"; // tls required for Amazon SES
$mail->SetFrom('x@x.com', 'x');
$mail->AddReplyTo('x@x.com', 'x');
$mail->AddAddress('x@x.com, 'x');
$mail->Subject = 'New Subject';
$mail->MsgHTML($body);
$mail->Send();
} 
catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} 
catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
?>

0 个答案:

没有答案