email authentication python
import smtplib
server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
server.login("your username", "your password")
server.sendmail(
"from@address.com",
"to@address.com",
"this message is from python")
server.quit()
python SMTP sendmail
#!/usr/bin/env python
import smtplib
from email.mime.text import MIMEText
sender = 'admin@example.com'
receivers = ['info@example.com']
port = 1025
msg = MIMEText('This is test mail')
msg['Subject'] = 'Test mail'
msg['From'] = 'admin@example.com'
msg['To'] = 'info@example.com'
with smtplib.SMTP('localhost', port) as server:
# server.login('username', 'password')
server.sendmail(sender, receivers, msg.as_string())
print("Successfully sent email")
|