13
回答
我想寫個Email程式想達成一些功能但不知如何做
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   

我想用python寫個Email想有一個介面可以一次過填入標題,收件人,內容...等等

讀取Email時也有這樣的介面

我想問可以怎樣做呢?

举报
jacklam
发帖于5年前 13回/285阅
共有13个答案 最后回答: 5年前
#Here is a minimal example (without error checking) that opens a #mailbox and retrieves and prints all messages:

import getpass, poplib

M = poplib.POP3('localhost')
M.user(getpass.getuser())
M.pass_(getpass.getpass())
numMessages = len(M.list()[1])
for i in range(numMessages):
    for j in M.retr(i+1)[1]:
        print j

#At the end of the module, there is a test section that contains a #more extensive example of usage.

引用来自“Duke.Yee”的答案

#Here is a minimal example (without error checking) that opens a #mailbox and retrieves and prints all messages:

import getpass, poplib

M = poplib.POP3('localhost')
M.user(getpass.getuser())
M.pass_(getpass.getpass())
numMessages = len(M.list()[1])
for i in range(numMessages):
    for j in M.retr(i+1)[1]:
        print j

#At the end of the module, there is a test section that contains a #more extensive example of usage.

謝謝解答這應該是讀取吧,我想問例如發送email時有個命令行的介面有些收件人,標題,內容輸入框然後可能按某個接鍵就發送呢.


import smtplib
smtp = smtplib.SMTP()
smtp.connect('smtp.126.com', 25)
smtp.login('XXXX@126.com', 'YYYYY')
smtp.sendmail('XXXX@126.com', 
    ['abc@abc.com'], 'test') 

引用来自“Duke.Yee”的答案

import smtplib
smtp = smtplib.SMTP()
smtp.connect('smtp.126.com', 25)
smtp.login('XXXX@126.com', 'YYYYY')
smtp.sendmail('XXXX@126.com', 
    ['abc@abc.com'], 'test') 
謝謝你給力的解答!我會試試
顶部