It won't work before we've connected to the server:
Traceback (most recent call last):
...
File ".\rss2email\email.py", line 145, in smtp_send
smtp.ehlo()
...
smtplib.SMTPServerDisconnected: please run connect() first
That makes sense ;). If we want to call ehlo(), we should certainly
do it after the .connect() call succeeds. Looking at the docs [1], I
don't think we need to call it at all:
Unless you wish to use has_extn() before sending mail, it should not
be necessary to call this method explicitly. It will be implicitly
called by sendmail() when necessary.
We don't use has_extn(), and the EHLO should happen implicitly in
starttls [2]:
If there has been no previous EHLO or HELO command this session,
this method tries ESMTP EHLO first.
and send_message [3]:
This is a convenience method for calling sendmail()...
via sendmail [4]:
If there has been no previous EHLO or HELO command this session,
this method tries ESMTP EHLO first.
[1]: http://docs.python.org/3/library/smtplib.html#smtplib.SMTP.ehlo
[2]: http://docs.python.org/3/library/smtplib.html#smtplib.SMTP.starttls
[3]: http://docs.python.org/3/library/smtplib.html#smtplib.SMTP.send_message
[4]: http://docs.python.org/3/library/smtplib.html#smtplib.SMTP.sendmail
Reported-by: Matt Bordignon <matthew@bordignons.net>
Signed-off-by: W. Trevor King <wking@tremily.us>
smtp = _smtplib.SMTP_SSL()
else:
smtp = _smtplib.SMTP()
- smtp.ehlo()
try:
smtp.connect(SMTP_SERVER)
except KeyboardInterrupt: