Created
September 23, 2015 08:25
-
-
Save kerbyfc/7977af99dcbab8cf1b11 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/python | |
# -*- coding: utf-8 -*- | |
import socket | |
import sys | |
__author__ = 'serebryakov' | |
from smtplib import SMTP | |
from email.mime.text import MIMEText | |
SMTP_SERVER = sys.argv[1] | |
SMTP_PORT = 25 | |
HOST = socket.gethostname() | |
TEXT = sys.argv[2] or "строго кониденциально" | |
SUBJECT = len(sys.argv) > 3 and sys.argv[3] or "[from " + HOST + "]" | |
person1 = '[email protected]' | |
person2 = '[email protected]' | |
FROM = [person1] | |
TO = [person2] | |
def send_mail(msg): | |
print("send to " + SMTP_SERVER + ":" + str(SMTP_PORT)) | |
s = SMTP(SMTP_SERVER, SMTP_PORT) | |
s.sendmail(FROM, TO, msg.as_string()) | |
s.close() | |
def create_simple_message(subj, body): | |
msg = MIMEText(body) | |
msg['Subject'] = subj | |
return msg | |
if __name__ == '__main__': | |
send_mail(create_simple_message(SUBJECT, TEXT)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment