Python Forum
Start tls - Unable to send email
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Start tls - Unable to send email
#1
Hi Team,

Start tls ()is throwing below error

Error:
send: 'STARTTLS\r\n' reply: '220 2.0.0 SMTP server ready\r\n' reply: retcode (220); Msg: 2.0.0 SMTP server ready Unexpected error: <class 'ssl.SSLEOFError'> Traceback (most recent call last): File "./kad.py", line 24, in <module> server.starttls() File "/usr/lib64/python2.7/smtplib.py", line 648, in starttls self.sock = ssl.wrap_socket(self.sock, keyfile, certfile) File "/usr/lib64/python2.7/ssl.py", line 936, in wrap_socket ciphers=ciphers) File "/usr/lib64/python2.7/ssl.py", line 611, in __init__ self.do_handshake() File "/usr/lib64/python2.7/ssl.py", line 833, in do_handshake self._sslobj.do_handshake() ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:579)
import sys
import smtplib
import email.utils
from email.mime.text import MIMEText

# Create the message
msg = 'This is the body of the message.'
FROMADDR = "[email protected]"
TOADDRS  = "[email protected]"


server = smtplib.SMTP(host='<smtp server>',port=25)
server.set_debuglevel(True) # show communication with the server
print msg

try:
    server.starttls()
    server.ehlo()
    server.sendmail(FROMADDR,TOADDRS,msg)
except:
        print "Unexpected error:", sys.exc_info()[0]
raise
Thanks
A
Reply


Messages In This Thread
Start tls - Unable to send email - by darunkumar - May-12-2018, 10:00 AM
RE: Start tls - Unable to send email - by ljmetzger - May-12-2018, 04:30 PM
RE: Start tls - Unable to send email - by ljmetzger - May-14-2018, 01:01 PM
RE: Start tls - Unable to send email - by ljmetzger - May-14-2018, 08:48 PM
RE: Start tls - Unable to send email - by ljmetzger - May-15-2018, 07:42 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Email, certificate verify failed: unable to get local issuer certificate SpongeB0B 0 1,626 Feb-08-2023, 02:24 PM
Last Post: SpongeB0B
  Send Email with attachment metro17 4 3,274 Apr-14-2020, 04:59 PM
Last Post: CodeItBro
  Send an email Jokoba 0 2,552 Mar-12-2020, 05:30 PM
Last Post: Jokoba
  Help send email by Python using smtplib hangme 6 6,216 Jan-25-2020, 03:31 AM
Last Post: shapeg

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020