Python SMTP Server with SSL: handshake error

1.3k Views Asked by At

I use lib secure_smtpd for create SMTP server. When I generate certificate and use it for SSL connection I catch exception (for test I use Opera mail client and The Bat!):

SSLError: _ssl.c:489: The handshake operation timed out

When I test use python script everything is ok:

smtpObj = smtplib.SMTP_SSL('localhost',2000)
smtpObj.set_debuglevel(1)
smtpObj.login('testuser', '111111')

msg = MIMEMultipart('alternative')
msg['Subject'] = "my subj SSL"
msg['From'] = sender
msg['To'] = "[email protected]"
msg.attach(MIMEText("Hello world!",'html'))
smtpObj.sendmail(sender, [toemail], msg.as_string())

Can somebody help fix problem with handshake? I use python 2.7.3

1

There are 1 best solutions below

2
On

How you configured SMTP in Opera and The Bat! ? There is SSL mode (which you seems to use), where all connection is wrapped in SSL/TLS, and STARTTLS mode, where connection is plain but SSL/TLS excahnge is started after client issues STARTTLS command.