Skip to content

Instantly share code, notes, and snippets.

@catichenor
Created April 6, 2020 20:52
Show Gist options
  • Save catichenor/c86c1b4cbd4b67eb8d28108b2641f7d6 to your computer and use it in GitHub Desktop.
Save catichenor/c86c1b4cbd4b67eb8d28108b2641f7d6 to your computer and use it in GitHub Desktop.
How to authenticate to yagmail on an SMTP server without authentication
# Couldn't find a reference on how to authenticate to an SMTP server that doesn't require authentication, but this worked.
# Based on the yagmail PyPi page: https://pypi.org/project/yagmail/
# and yagmail docs: https://yagmail.readthedocs.io/en/latest/api.html#smtp-client
import yagmail
user_email = "my_email@somedomain.com"
yag = yagmail.SMTP(user=user_email, host='smtp.somedomain.com', port=25, smtp_skip_login=True, smtp_ssl=False)
contents = [
"This is the body, and here is just text http://somedomain/image.png",
"You can find an audio file attached.", '/local/path/to/song.mp3'
]
yag.send('some_email@anotherdomain.com', 'Testing', contents)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment