简体   繁体   English

使用 Amazon AWS SES 发送电子邮件

[英]Sending emails using Amazon AWS SES

I have configured aws's ses service but have not been able to use it.我已经配置了aws的ses服务但是一直无法使用。 My emails are being sent but they are sent through my hosting server (Godaddy) and I would want to send them only through AWS's SES.我的电子邮件正在发送,但它们是通过我的托管服务器 (Godaddy) 发送的,我只想通过 AWS 的 SES 发送它们。 Pardon me, if I have made a rookie mistake.请原谅我,如果我犯了一个新手错误。

Here's what my code looks like这是我的代码的样子

<?php
require 'PHPMailerAutoload.php';
require 'class.phpmailer.php';
$mail = new PHPMailer;
$mail->SMTPDebug = 2;
$mail->Host = 'email-smtp.eu-west-1.amazonaws.com';
$mail->Port = 25;
$mail->ssl = true;
$mail->authentication = true;
$mail->Username = 'username';
$mail->Password = 'password';
$mail->setFrom('vaibhav@zigsaw.in', 'Test Email');
$mail->Body = 'Test Email from Zigsaw';
$mail->AddReplyTo('zigsawconsultancy@gmail.com', 'Candidate');
$mail->addAddress('zigsawconsultancy@gmail.com', 'Recruiter');
$mail->Subject = 'Test Email from Zigsaw';
if(!$mail->send()) 
{
echo "Email not sent. " , $mail->ErrorInfo , PHP_EOL;
} 
else 
{
echo "Email sent!" , PHP_EOL;
}
?>

Disclaimer: My file is hosted on a godaddy server and I am trying to send emails through AWS SES.免责声明:我的文件托管在 Godaddy 服务器上,我正在尝试通过 AWS SES 发送电子邮件。

GoDaddy blocks outbound SMTP, but you've not told PHPMailer to use SMTP (so most of your settings do nothing), so it's submitting via the mail() function, using a local mail server, which in GoDaddy's case is their server - so that's why it's going that way. GoDaddy 阻止出站 SMTP,但您没有告诉 PHPMailer 使用 SMTP(所以您的大部分设置什么都不做),所以它通过 mail() 函数提交,使用本地邮件服务器,在 GoDaddy 的情况下是他们的服务器 - 所以这就是为什么它会这样。 Unfortunately there isn't a way of using external SMTP on GoDaddy, though you can send via their secureserver.net relay - but that of course means you can't send using your personal domain because it's forgery and you messages will be spam-filtered or bounced.不幸的是,没有办法在 GoDaddy 上使用外部 SMTP,尽管您可以通过他们的secureserver.net中继发送 - 但这当然意味着您不能使用您的个人域发送,因为它是伪造的并且您的邮件将被垃圾邮件过滤或反弹。

If you call:如果你打电话:

$mail->isSMTP();

PHPMailer will use SMTP and your other settings, though as I said in my comment, you've just invented a bunch of things that will not work, so rewrite your code based on the examples provided, though this won't work on GoDaddy. PHPMailer 将使用 SMTP 和您的其他设置,但正如我在我的评论中所说,您刚刚发明了一堆不起作用的东西,因此根据提供的示例重写您的代码,尽管这在 GoDaddy 上不起作用。

If SES has an HTTP API, so you may be able to use that instead, since it will not be subject to GoDaddy's blocking.如果 SES 有 HTTP API,那么您可以改用它,因为它不会受到 GoDaddy 的阻止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM