I want to send a mail in using python, below is my code, but I got the error 10061 at the end, hope anyone can help me, thanks!
import smtplib
fromaddr = \'X
As far as I know Gmail and other companies have security to prevent emails being sent from unknown sources, but this link can turn that kind of security off.
There you can modify the account so it will accept the email.
I use this code to send email:
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from_address = 'johndoe@gmail.com'
to_address = 'johndoe@gmail.com'
message = MIMEMultipart('Foobar')
epos_liggaam['Subject'] = 'Foobar'
message['From'] = from_address
message['To'] = to_address
content = MIMEText('Some message content', 'plain')
message.attach(content)
mail = smtplib.SMTP('smtp.gmail.com', 587)
mail.ehlo()
mail.starttls()
mail.login(from_address, 'password')
mail.sendmail(from_address,to_address, message.as_string())
mail.close()