/--------------------------------------------check/receive mail-------------------------------------------------------------/
#!/usr/bin/python
#check message
import getpass, poplib
import sys
M = poplib.POP3('pop3.163.com')
print M.getwelcome()
M.user(sys.argv[1])
M.pass_(sys.argv[2])
M.list()
numMessages = len(M.list()[1])
print 'mails :',numMessages
print '------------------------'
M.quit()
/****************************send mail *******************************************/
#!/usr/bin/python
import smtplib
def prompt(prompt):
return raw_input(prompt).strip()
from_addr = prompt("From:")
to_addrs = prompt("To").split()
print 'Enter message ,end with ^D'
msg = ("From:%s\r\nTo:%s\r\n\r\n"
%(from_addr,",".join(to_addrs)))
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('smtp.163.com')
server.login('YOUR_ID','YOUR_PASSWORD')
server.set_debuglevel(1)
server.sendmail(from_addr,to_addrs,msg)
server.quit()
阅读(1403) | 评论(0) | 转发(0) |