Skip to content

Instantly share code, notes, and snippets.

@entrity
Created June 9, 2021 22:47
Show Gist options
  • Select an option

  • Save entrity/72e40e5267fe19814c28a58ebe0ebdba to your computer and use it in GitHub Desktop.

Select an option

Save entrity/72e40e5267fe19814c28a58ebe0ebdba to your computer and use it in GitHub Desktop.

Revisions

  1. entrity created this gist Jun 9, 2021.
    27 changes: 27 additions & 0 deletions python-cgi-mailer.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    import smtplib
    import cgi

    FROM_ADDR = ''
    TO_ADDR = ''
    USERNAME = FROM_ADDR
    PASSWORD = ''
    LOG_DIR = '.'

    print 'foo'

    def send_email(message):
    server = smtplib.SMTP(SMTP_HOST, 587, DOMAIN)
    server.ehlo()
    server.starttls()
    server.ehlo()
    server.login(USERNAME, PASSWORD)
    server.sendmail(FROM_ADDR, TO_ADDR, message)
    server.quit()

    def build_message():
    return "From: %s\r\nSubject: From Form\r\nTo: %s\r\n\r\nbody" % (FROM_ADDR, TO_ADDR)

    def get_cgi():
    return cgi.FieldStorage()

    send_email(get_cgi())