自定义脚本,脚本使用python 写的代码如下
#!/usr/bin/env python#-*- coding:utf-8 -*-import smtplibimport systo_addr=sys.argv[1]subject_header=sys.argv[2]body=sys.argv[3]def Sendmail(to_addr='regina.chen@mencoplatform.com',subject_header='Test',body='This is just for test'): subject_header = 'Subject:' + subject_header + '\r' mail_server = 'smtp.163.com' mail_server_port = 25 from_addr = 'mencomonitor@163.com' from_header = 'From:%s\r' %from_addr smtp = smtplib.SMTP() smtp.connect(mail_server,mail_server_port) smtp.login('mencomonitor','yourpassord') to_header = 'To:%s\r' % to_addr email_message = '%s\n%s\n%s\n\r\n%s' %(from_header,to_header,subject_header,body) smtp.sendmail(from_addr, to_addr, email_message) smtp.quit()if __name__ == '__main__': Sendmail(to_addr = to_addr,subject_header = subject_header, body = body)