Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
for the times when you just want to send an email and you don't want to setup postfix because you don't care about the email all that much...
#!/usr/bin/env python
import argparse
from email import message_from_string
import smtplib
import sys
def justsend():
parser = argparse.ArgumentParser(description="Just send and email message to a SMTP server.") # noqa
parser.add_argument("-a", "--address", action="store", dest="address", type=str, # noqa
help="host:port of SMTP server to send email to",
args = parser.parse_args()
msg = message_from_string(
s = smtplib.SMTP(args.address)
to = None
if isinstance(msg['To'], list):
to = msg['To']
to = [msg['To']]
s.sendmail(msg['From'], to, msg.as_string())
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.