Sending Email With Python Via Gmail
Email Sending In Python
Sending an email using python:
source code below:
import smtplib
import confidential
def send_my_email(myemail,password):
try:
server=smtplib.SMTP_SSL("smtp.gmail.com",465)
server.login(myemail,password)
server.sendmail(myemail,myemail,"Hello its a test")
server.quit()
print("Email sent succesfully")
except:
print("Email not sent")
send_my_email(confidential.EMAIL_ACC,confidential.PASSWORD)
Copy the source code above and the confidential file is down below:
EMAIL_ACC="youremail@gmail.com"
PASSWORD="use-your-own-password"
and save it as a .py file


Comments
Post a Comment