Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''Send email with attachments using gmail.
- By Steve Shambles.
- stevepython.wordpress.com
- pip3 install yagmail
- '''
- import yagmail
- # set up your gmail credentials.
- # any problems could be gmail blocking you or wrong pw etc.
- # I had to allow unsafe apps in my gmail security
- # settings to get this to work.
- YAG_SMTP = yagmail.SMTP(user="your@gmail.com",
- password="your-password",
- host='smtp.gmail.com')
- # email subject
- SUBJECT = 'Yagmail Test'
- # email content with attached file from current dir.
- CONTENTS = ['Hi Dude', 'image attached innit.', 'some-image.jpg']
- # send mail
- YAG_SMTP.send('person@anymail.com', SUBJECT, CONTENTS)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement