AWS SES设置 - 无法发送测试邮件

问题描述 投票:0回答:1

我按照this document配置了AWS SES。

无法从SES“已验证”的电子邮件ID([email protected])发送邮件

如果我从AWS EC2实例运行此代码,则会出现空白页或500错误。没有看到与该问题有关的错误消息。

<?php
// If necessary, modify the path in the require statement below to refer to the
// location of your Composer autoload.php file.
require 'vendor/autoload.php';
use PHPMailer\PHPMailer\PHPMailer;
// Instantiate a new PHPMailer
$mail = new PHPMailer;
// Tell PHPMailer to use SMTP
$mail->isSMTP();
// Replace [email protected] with your "From" address.
// This address must be verified with Amazon SES.
$mail->setFrom('[email protected]', 'rimo ');
// Replace [email protected] with a "To" address. If your account
// is still in the sandbox, this address must be verified.
// Also note that you can include several addAddress() lines to send
// email to multiple recipients.
$mail->addAddress('[email protected]', 'Vikas');
// Replace smtp_username with your Amazon SES SMTP user name.
$mail->Username = 'concealed';
// Replace smtp_password with your Amazon SES SMTP password.
$mail->Password = 'concealed';
// Specify a configuration set. If you do not want to use a configuration
// set, comment or remove the next line.
//$mail->addCustomHeader('X-SES-CONFIGURATION-SET', 'ConfigSet');
// If you're using Amazon SES in a region other than US West (Oregon),
// replace email-smtp.us-west-2.amazonaws.com with the Amazon SES SMTP
// endpoint in the appropriate region.
$mail->Host = 'email-smtp.us-east-1.amazonaws.com';
// The subject line of the email
$mail->Subject = 'Amazon SES test (SMTP interface accessed using PHP)';
// The HTML-formatted body of the email
$mail->Body = '<h1>Email Test</h1>
    <p>This email was sent through the
    <a href="https://aws.amazon.com/ses">Amazon SES</a> SMTP
    interface using the <a href="https://github.com/PHPMailer/PHPMailer">
    PHPMailer</a> class.</p>';
// Tells PHPMailer to use SMTP authentication
$mail->SMTPAuth = true;
// Enable TLS encryption over port 587
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
// Tells PHPMailer to send HTML-formatted email
$mail->isHTML(true);
// The alternative email body; this is only displayed when a recipient
// opens the email in a non-HTML email client. The \r\n represents a
// line break.
$mail->AltBody = "Email Test\r\nThis email was sent through the
    Amazon SES SMTP interface using the PHPMailer class.";
if(!$mail->send()) {
    echo "Email not sent. " , $mail->ErrorInfo , PHP_EOL;
} else {
    echo "Email sent!" , PHP_EOL;
}
?>
amazon-ec2 phpmailer amazon-ses
1个回答
0
投票

您可以尝试在PHP邮件程序中启用调试并从CLI执行它。

php filename.php https://github.com/PHPMailer/PHPMailer/wiki/SMTP-Debugging

您应该能够看到问题所在。

© www.soinside.com 2019 - 2024. All rights reserved.