macOS tools moving to my git
This commit is contained in:
59
send_quitbrowsers_mail3.py
Executable file
59
send_quitbrowsers_mail3.py
Executable file
@@ -0,0 +1,59 @@
|
||||
# Settings
|
||||
|
||||
SMTP_SERVER = 'emailz.d27n.com'
|
||||
SMTP_PORT = 587
|
||||
SMTP_USERNAME = 'steve@d27n.com'
|
||||
SMTP_PASSWORD = 'L2sC7JikwX'
|
||||
SMTP_FROM = 'angus@d27n.com'
|
||||
SMTP_TO = 'steve@d27n.com'
|
||||
|
||||
SUBJECT = '[Angus] Token Saver Activated!'
|
||||
TEXT_FILENAME = '/script/output/my_attachment.txt'
|
||||
MESSAGE = """Stop being a useless drunk.
|
||||
"""
|
||||
|
||||
# Now construct the message
|
||||
import smtplib, email
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from email.mime.base import MIMEBase
|
||||
from email import encoders
|
||||
|
||||
#msg = email.MIMEMultipart.MIMEMultipart()
|
||||
#body = email.MIMEText.MIMEText(data)
|
||||
#attachment = email.MIMEBase.MIMEBase('text', 'plain')
|
||||
#attachment.set_payload(open(TEXT_FILENAME).read())
|
||||
#attachment.add_header('Content-Disposition', 'attachment', filename=os.path.basename(TEXT_FILENAME))
|
||||
#encoders.encode_base64(attachment)
|
||||
#msg.attach(body)
|
||||
#msg.attach(attachment)
|
||||
#msg.add_header('From', SMTP_FROM)
|
||||
#msg.add_header('To', SMTP_TO)
|
||||
#msg.add_header('Subject', SUBJECT)
|
||||
|
||||
# Now send the message
|
||||
#mailer = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
|
||||
# EDIT: mailer is already connected
|
||||
# mailer.connect()
|
||||
#mailer.login(SMTP_USERNAME, SMTP_PASSWORD)
|
||||
#mailer.sendmail(SMTP_FROM, [SMTP_TO], msg.as_string())
|
||||
#mailer.close()
|
||||
|
||||
#creating the SMTP server object by giving SMPT server address and port number
|
||||
smtp_server=smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
|
||||
smtp_server.ehlo() #setting the ESMTP protocol
|
||||
#smtp_server.starttls() #setting up to TLS connection
|
||||
#smtp_server.ehlo() #calling the ehlo() again as encryption happens on calling startttls()
|
||||
smtp_server.login(SMTP_USERNAME, SMTP_PASSWORD) #logging into out email id
|
||||
|
||||
msg_to_be_sent = MESSAGE
|
||||
|
||||
message = MIMEMultipart()
|
||||
message['From'] = SMTP_FROM
|
||||
message['To'] = SMTP_TO
|
||||
message['Subject'] = SUBJECT
|
||||
message.attach(MIMEText(msg_to_be_sent, 'plain'))
|
||||
|
||||
#sending the mail by specifying the from and to address and the message
|
||||
smtp_server.sendmail( SMTP_FROM, SMTP_TO, message.as_string())
|
||||
smtp_server.quit() #terminating the server
|
||||
Reference in New Issue
Block a user