Amazon SES SMTP Python Usage

综合编程 2018-05-26 阅读原文

I am trying to diagnose why sending email through Amazon SES is not working via python.

The following example demonstrates the problem, where user
and pass
are set to the appropriate credentials.

>>> import smtplib
>>> s = smtplib.SMTP_SSL("", 465)
>>> s.login(user, pw)
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.6/", line 549, in login
  File "/usr/lib/python2.6/", line 510, in ehlo_or_helo_if_needed
    (code, resp) = self.helo()
  File "/usr/lib/python2.6/", line 372, in helo
  File "/usr/lib/python2.6/", line 340, in getreply
    raise SMTPServerDisconnected("Connection unexpectedly closed")
smtplib.SMTPServerDisconnected: Connection unexpectedly closed

This message is not particularly useful, and have tried other vraiations, but can't seem to get it to work.

I can send email using my thunderbird email client with these settings, so my assumption is that I am mission something TLS-related.

I don't think SMTP_SSL works anymore with SES. One must use starttls()

smtp = smtplib.SMTP("")
smtp.sendmail(me, you, msg)
Hello, buddy!

责编内容by:Hello, buddy!阅读原文】。感谢您的支持!


Python标准库(3.x): 内建函数扫盲 Built-in Functions abs( x ) 求一个数的绝对值。 >>> abs(13) 13 >>> abs(-15) 15...
Python’s founder steps down, India’s n... In this edition of our open source news roundup, we take a look Python's founder stepping down, India's new net neutrality regulations, O'Reilly's tho...
Enhance your Python with an interactive shell The Python programming language has become one of the most popular languages used in IT. One reason for this success is it can be used to solve a vari...
(sukhoi) Flexible and extensible Webcrawler in pyt... Sukhoi Minimalist and powerful Web Crawler. Sukhoi is built on top of the concept of miners, it is similar to what happens with scrapy and its spi...
静态类型检查器 Mypy 0.620 发布,支持 Data Classes... Mypy 0.620 已发布,包含一些新特性和 bug 修复。Mypy 是 Python 的可选静态类型检查器,旨在结合动态类型和静态类型的优点。新版本可按如下方式安装: python3 -m pip install -U mypy 亮点包括: 支持 Python 3.7...