amazon-web-services - Pyramid_exclog : SMTPAuthenticationError: (530, 'Must issue a STARTTLS command first' )

标签 amazon-web-services exception smtp pyramid

我正在使用 pyramid_exclog 记录异常并将这些异常作为电子邮件发送。我正在使用 Amazon aws SMTP 发送电子邮件。但是我收到以下错误:

SMTPAuthenticationError: (530, 'Must issue a STARTTLS command first')

这是我使用的代码:

[handler_email_exc_handler]
class = handlers.SMTPHandler
args = (('email-smtp.us-east-1.amazonaws.com', 587), 'no-reply@company.com', ['me@company.com'], 'Company Exception' ,('<username>','<user_key>'),None)
level = ERROR
formatter = exc_formatter

据我所知,aws 凭证没有任何问题,因为我使用它们通过 Thunderbird 发送邮件。

最佳答案

这不是凭据,至少根据此错误消息不是。您正在尝试在不使用 TLS 的情况下与 SES 进行 SMTP 通信——您正在尝试通过未加密的连接验证您自己的身份。这不安全,因为它可能会导致您的凭据泄露,因此不受支持。

The Amazon SES SMTP endpoint requires that all connections be encrypted using Transport Layer Security (TLS). (Note that TLS is often referred to by the name of its predecessor protocol, SSL.) Amazon SES supports two mechanisms for establishing a TLS-encrypted connection: STARTTLS and TLS Wrapper. Check the documentation for your software to determine whether it supports STARTTLS, TLS Wrapper, or both.

If your software does not support STARTTLS or TLS Wrapper, you can use the open source stunnel program to set up an encrypted connection (called a "secure tunnel"), then use the secure tunnel to connect to the Amazon SES SMTP endpoint.

http://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-connect.html

我不是 Python 专家,但快速检查一下 Google 机器表明:

To specify the use of a secure protocol (TLS), pass in a tuple to the secure argument. This will only be used when authentication credentials are supplied. The tuple should be either an empty tuple, or a single-value tuple with the name of a keyfile, or a 2-value tuple with the names of the keyfile and certificate file. (This tuple is passed to the smtplib.SMTP.starttls() method.)

https://docs.python.org/2/library/logging.handlers.html

啊哈,它甚至提到了“starttls”。

如果我找到了正确的引用,也许您的最后一个参数应该是 () 而不是 None,因为您不需要 key 文件或证书文件。

关于amazon-web-services - Pyramid_exclog : SMTPAuthenticationError: (530, 'Must issue a STARTTLS command first' ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31872336/

相关文章:

php - 如何使用一些简短的方法将所有文件和文件夹从一个文件夹移动到另一个文件夹中的 S3 存储桶?

C# System.InvalidOperationException : The current TransactionScope is already complete

exception - 如何避免加载网页时因 watir-webdriver 超时错误导致程序终止?

google-app-engine - Google App Engine 可以使用第三方 SMTP 服务器吗?

ruby - 帮助解决在 ruby​​ 中使用邮件的问题

c# - 如何使用 C# 复制 AmazonS3 存储桶中的文件夹?

python-2.7 - IO错误 : No such file or directory:

amazon-web-services - 2 个 Cloudfront 发行版之间的加权循环 DNS

java - Spring JPA - 处理 DB/Repo 异常

smtp - Postfix - 必须首先发出 STARTTLS 命令