使用PHPMailer和Amazon SES [英] Using PHPMailer and Amazon SES

查看:87
本文介绍了使用PHPMailer和Amazon SES的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Amazon SES .我正在尝试使用 PHPMailer 从我的 PHP 脚本发送电子邮件.

I am using Amazon SES. I am trying to send an email from my PHP script using PHPMailer.

我已经验证了两个电子邮件ID,并尝试从该电子邮件ID发送邮件到该电子邮件ID.但这会引发以下错误.

I already verified two email ids and trying to send mail from and to this mail ids. But It throws the following error.

SERVER -> CLIENT: 220 email-smtp.amazonaws.com ESMTP SimpleEmailService-693939519  QEPGeLndQQq5vJ53VMXU
CLIENT -> SERVER: EHLO localhost
SERVER -> CLIENT: 250-email-smtp.amazonaws.com250-8BITMIME250-SIZE 10485760250- STARTTLS250-AUTH PLAIN LOGIN250 Ok
CLIENT -> SERVER: STARTTLS
SERVER -> CLIENT: 220 Ready to start TLS
CLIENT -> SERVER: EHLO localhost
SERVER -> CLIENT: 250-email-smtp.amazonaws.com250-8BITMIME250-SIZE 10485760250-STARTTLS250-AUTH PLAIN LOGIN250 Ok
CLIENT -> SERVER: AUTH LOGIN


SMTP NOTICE: EOF caught while checking if connected
SMTP connect() failed.
Mailer Error: SMTP connect() failed.

以下是我的 PHP脚本:

<?php

//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have   access to that
date_default_timezone_set('Etc/UTC');

require 'phpmailer/PHPMailerAutoload.php';

//Create a new PHPMailer instance
$mail = new PHPMailer();

//Tell PHPMailer to use SMTP
$mail->isSMTP();

//Enable SMTP debugging

$mail->SMTPDebug = 2;

//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';

//Set the hostname of the mail server
$mail->Host = 'email-smtp.us-east-1.amazonaws.com';

//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
// I tried PORT 25, 465 too
$mail->Port = 587;

//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = 'tls';

//Whether to use SMTP authentication
$mail->SMTPAuth = true;

//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = "SES Secret ID";

//Password to use for SMTP authentication
$mail->Password = "SES Secret Key";

//Set who the message is to be sent from
$mail->setFrom('sender@example.com', 'sender');

//Set who the message is to be sent to
$mail->addAddress('receiver@example.com', 'receiver');

//Set the subject line
$mail->Subject = 'PHPMailer GMail SMTP test';


$mail->Body = 'This is a plain-text message body';
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';

//send the message, check for errors
if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
}
?>

我尝试了很多在Internet上找到的解决方案,尤其是 stackoverflow .

I tried so many solutions I found over the internet, especially stackoverflow.

没有任何效果!

推荐答案

我设法使其正常运行.

I managed to make it work.

$ mail-> Port = 587; 

// Username to use for SMTP authentication - use full email address for gmail 
$ mail-> Username = "Amazon SES Secret ID"; 

// Password to use for SMTP authentication 
$ mail-> Password = "Amazon SES Secret Key"; 

要创建凭据,请访问以下链接: https://console. aws.amazon.com/ses/home?region=us-east-1#smtp-settings :

To create credentials visit this link: https://console.aws.amazon.com/ses/home?region=us-east-1#smtp-settings:

要发送电子邮件,既要发送电子邮件,也要发送电子邮件,因为您收到的电子邮件必须由亚马逊注册和检查. ( https://console.aws.amazon.com/ses/home?region = us-east-1#verified-senders-mail :)

To send e-mail, both sending email, as the email you receive will necessarily have to be registered and checked by amazon. (https://console.aws.amazon.com/ses/home?region=us-east-1#verified-senders-mail:)

任何问题都可以找到我. 希望我能帮忙

Any questions you can find me. I hope I helped

这篇关于使用PHPMailer和Amazon SES的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆