【发布时间】:2025-12-17 05:00:01
【问题描述】:
我想通过 Amazon SES 服务上的 php mail 发送邮件,在使用 PHP Mail 但我无法发送发送。我已经验证了我的 email_id。我使用本教程作为参考http://www.codeproject.com/Articles/786596/How-to-Use-Amazon-SES-to-Send-Email-from-PHP。 但它不是从 Amazon SES 服务发送邮件,请告诉我哪里错了? 以前我使用相同的 id 从本地服务器 XAMPP 发送邮件。它工作正常。
sendMail.php
<?php >
function Send_Mail($to,$subject,$body)
{
require 'class.phpmailer.php';
$from = "Senders_Email_Address";
$mail = new PHPMailer();
$mail->IsSMTP(true); // SMTP
$mail->SMTPAuth = true; // SMTP authentication
$mail->Mailer = "smtp";
$mail->Host= "tls://email-smtp.us-east.amazonaws.com"; // Amazon SES
$mail->Port = 465; // SMTP Port
$mail->Username = "Senders_Email_Address"; // SMTP Username
$mail->Password = "MyPassword"; // SMTP Password
$mail->SetFrom($from, 'From Name');
$mail->AddReplyTo($from,'Senders_Email_Address');
$mail->Subject = $subject;
$mail->MsgHTML($body);
$address = $to;
$mail->AddAddress($address, $to);
if(!$mail->Send())
return false;
else
return true;
}
?>
index.php
<html>
<body>
<h1>Welcome to my home page!</h1>
<p>Some text.</p>
<p>Some more text.</p>
<?php
require 'sendMail.php';
$to = "Senders_Email_Address";
$subject = "Test Mail Subject";
$body = "Hi<br/>Test Mail<br/>Amazon SES"; // HTML tags
Send_Mail($to,$subject,$body);
?>
</body>
</html>
sendMail.php、class.phpmailer.php、class.smtp.php和index.php在同一个目录。
【问题讨论】:
标签: php email amazon-web-services