Last active
February 2, 2024 04:16
-
-
Save ashafer01/1c1d8c551c3f4170c090f9d3bc68d61b to your computer and use it in GitHub Desktop.
Drop-in replacement for sendmail -t which relays to gmail smtp, should be easy to adapt to any smtp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import email | |
import smtplib | |
import sys | |
smtp_address = "smtp.gmail.com" | |
smtp_port = 587 | |
smtp_user_name = "[email protected]" | |
smtp_password = "YOUR_APP_PASSWORD" | |
with smtplib.SMTP(smtp_address, smtp_port) as smtp: | |
smtp.starttls() | |
smtp.login(smtp_user_name, smtp_password) | |
msg = email.message_from_string(sys.stdin.read()) | |
smtp.send_message(msg, from_addr=smtp_user_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment