Hi I am trying to send an email through python. I use this code to send:
server = smtplib.SMTP(host='send.one.com',port=465)
server.starttls()
server.login(USER, PASS)
text = msg.as_string()
server.sendmail(mailFrom, mailTo, text)
server.quit()
but I get an error on the first line:
File "/home/emil/Name_Generator/VoteMail.py", line 69, in sendVoteMail
server = smtplib.SMTP(host='send.one.com',port=465)
File "/usr/lib/python3.4/smtplib.py", line 242, in __init__
(code, msg) = self.connect(host, port)
File "/usr/lib/python3.4/smtplib.py", line 323, in connect
(code, msg) = self.getreply()
File "/usr/lib/python3.4/smtplib.py", line 376, in getreply
raise SMTPServerDisconnected("Connection unexpectedly closed")
smtplib.SMTPServerDisconnected: Connection unexpectedly closed
Has anyone else tried to connect to one.com smtp server with Python?
For everyone else that use one.com for your email and you want to connect to theire SMTP server thene I found out that they use SSL, and that was why my code did't work the proper way to do it is as follow:
server = smtplib.SMTP_SSL(host='send.one.com',port=465)
server.login(USER, PASS)
text = msg.as_string()
server.sendmail(mailFrom, mailTo, text)
server.quit()