#!/usr/bin/python
import smtplib
import sys
log_file = open('/tmp/mail.log','a')
log_file.write('test start')
def sendmail(**args):
host = 'smtp.126.com'
port = 25
user = 'yamoalq@126.com'
passwd = 'w'
smtp = smtplib.SMTP()
smtp.connect(host, port)
smtp.login(user, passwd)
smtp.sendmail(user, args['tomail'], 'From:yamoalq@126.com\nTO:%(tomail)s\nSubject:%(subject)s\n\n%(msg)s' % args)
smtp.quit()
tomail = sys.argv[1].split()
log_file.write(str(tomail))
subject = sys.argv[2]
log_file.write(subject)
msg = sys.argv[3]
log_file.write(msg)
sendmail(subject=subject,msg=msg,tomail=tomail)
log_file.close()
阅读(1771) | 评论(0) | 转发(0) |