Created
June 9, 2021 22:47
-
-
Save entrity/72e40e5267fe19814c28a58ebe0ebdba to your computer and use it in GitHub Desktop.
Python CGI mailer
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
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()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment