Tutorial
and test it again using the command line above
for which option is opt[1] useful?
what does opt[0] contain?
SMTP module
#!/usr/bin/python
import smtplib, string, sys, time
mailserver = "localhost"
From = string.strip(raw_input(’From: ’))
To = string.strip(raw_input(’To: ’))
Subject = string.strip(raw_input(’Subject: ’))
Date = time.ctime(time.time())
Header = (’From: %s\nTo: %s\nDate: %s\nSubject: %s\n\n’
% (From, To, Date, Subject))
Text = "my message"
server = smtplib.SMTP(mailserver)
failed = server.sendmail(From, To, Header + Text)
server.quit()
if failed:
print ’failed to send mail’
else:
print ’all done..’
没有评论:
发表评论