2024-04-25 22:54:18 发布
网友
使用smtplib。他们提供的example相当不错。
import smtplib def prompt(prompt): return raw_input(prompt).strip() fromaddr = prompt("From: ") toaddrs = prompt("To: ").split() print "Enter message, end with ^D (Unix) or ^Z (Windows):" # Add the From: and To: headers at the start! msg = ("From: %s\r\nTo: %s\r\n\r\n" % (fromaddr, ", ".join(toaddrs))) while 1: try: line = raw_input() except EOFError: break if not line: break msg = msg + line print "Message length is " + repr(len(msg)) server = smtplib.SMTP('localhost') server.set_debuglevel(1) server.sendmail(fromaddr, toaddrs, msg) server.quit()
如果它每周运行一次,您可能会从crontab运行它?
30 2 * * 5 python yourScript.py | mail -s outputFromScript your@email.address
您需要一个SMTP服务器来发送电子邮件。查看Python的smtplib
使用smtplib。他们提供的example相当不错。
如果它每周运行一次,您可能会从crontab运行它?
您需要一个SMTP服务器来发送电子邮件。查看Python的smtplib
相关问题 更多 >
编程相关推荐