Skip to content

Instantly share code, notes, and snippets.

@kavehbc
Created May 27, 2020 20:50
Show Gist options
  • Save kavehbc/89b937d0825b5335ae07c35472c4d9b1 to your computer and use it in GitHub Desktop.
Save kavehbc/89b937d0825b5335ae07c35472c4d9b1 to your computer and use it in GitHub Desktop.
Python - Sending email via yagmail
import yagmail
def sendGMail(email):
user = 'your_username@gmail.com'
app_password = 'your_app_password'
to = email
subject = 'test subject 1'
content = ['mail body content']
with yagmail.SMTP(user, app_password) as yag:
yag.send(to, subject, content)
print('Sent email successfully')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment