【发布时间】:2012-06-18 08:16:37
【问题描述】:
如何在我的Zend_Mail_Transport_Smtp 中使用 Amazon SES 密钥、密钥 + smtp 地址?
它说:Must issue a STARTTLS command first 尝试关注。
/*
Reference in C#: http://sesblog.amazon.com/
String username = "SMTP-USERNAME"; // Replace with your SMTP username.
String password = "SMTP-PASSWORD"; // Replace with your SMTP password.
String host = "email-smtp.us-east-1.amazonaws.com";
int port = 25;
*/
public static function sendEmail($to, $subject, $body) {
$config = array(
'aws_key' => 'yourkey',
'aws_secret' => 'yourkeysecret',
));
//
//echo 0 > /selinux/enforce
//$tr = new Zend_Mail_Transport_Smtp('smtp.belgacom.be');// works - for local
//$tr = new Zend_Mail_Transport_Smtp('out.telenet.be' ); // works - for office
//
$tr = new Zend_Mail_Transport_Smtp(
'email-smtp.us-east-1.amazonaws.com'); // DOES not work
Zend_Mail::setDefaultTransport($tr);
$mail = new Zend_Mail();
$html = self::setupEmail($body);
$mail->setBodyHtml($html);
$mail->setFrom('support@memy.com', 'memy.com');
$mail->addTo($to, 'EXAMPLE');
$mail->setSubject($subject);
$mail->send();
}
跟进:
// Wild guess
$config = array(
'aws_key' => 'yourkey',
'aws_secret' => 'yourkeysecret',
));
$tr = new Zend_Mail_Transport_Smtp('email-smtp.us-east-1.amazonaws.com',
$config);
最终跟进:
步骤 1) 要使用 Amazon SES SMTP 接口发送电子邮件,您将需要以下内容:
一个 AWS 账户。
-
Amazon SES 生产访问,如果您想发送大量电子邮件。有关详细信息,请参阅请求生产访问权限。
-- 完成后,他们允许
send 10000 emails per 24 hour period-- 不到 24 小时就可以快速激活
-- 5 封电子邮件/秒
-
您已通过 Amazon SES 验证的电子邮件地址。有关详细信息,请参阅验证电子邮件地址。
-- 这需要一段时间才能被他们验证
-- 24 小时后仍未确认
-
SMTP 接口主机名和端口号。主机名是 email-smtp.us-east-1.amazonaws.com。端口号因连接方法而异。有关详细信息,请参阅连接到 SMTP 端点。
-- 其他很重要,它失败了
您从 AWS 管理控制台获取的 SMTP 用户名和密码。有关详细信息,请参阅 SMTP 凭据。
可以使用 TLS(传输层安全)进行通信的客户端软件。
第 2 步) 我已经完成了上述操作,在管理控制台中显示:
Status:
pending verification (resend)
Please check your inbox for an email to this address, and click on the link provided to complete verification. If you did not receive this email, please click resend.
Domain verification in AWS:
Status:
pending verification (resend)
Please check your inbox for an email to this address, and click on the link provided to complete verification. If you did not receive this email, please click resend.
也就是说,他们会在 72 小时内做某事
第 3 步) 修改 $config 而不使用外部适配器(ZF 未移动)
$config = array(
'auth' => 'login',
'username' => 'SES key',
'password' => 'SES secret',
));
$tr = new Zend_Mail_Transport_Smtp('email-smtp.us-east-1.amazonaws.com',
$config);
【问题讨论】:
标签: php zend-framework amazon-ec2 zend-mail amazon-ses