请教:发邮件发送代码有错误,被服务器拒收,我找不到问题出在哪里

def sendfile(filepath):

from_mail=‘**@163.com’

to_mail=‘**@qq.com’

msg=MIMEMultipart()

msg[‘From’]=from_mail

msg[‘To’]=to_mail

msg[‘Subject’]=’subject’

content=MIMEText(open(filepath, ‘r’).read(), ‘base64’, ‘gb2312’)

content[“Content-Type”] = ‘application/octet-stream’

content.add_header(‘content-disposition’,’attachment’,filename=filepath)

msg.attach(content)

server=smtplib.SMTP(‘smtp.163.com’)

server.docmd(‘ehlo’,‘**@163.com’)

server.login(‘@163.com’,’**‘)

server.sendmail(from_mail,to_mail,msg.as_string())

server.quit()

def sendall():

for root, dirs, files in os.walk(‘D:/foolbak/‘):

for one in files:

tempfile=root+’/‘+one

sendfile(tempfile)

time.sleep(30)

讨论数量: 3

...整理一下代码,用markdown语法插入代码 :flushed:,然后贴出来你报错的错误信息,也用markdown语法。。。

3年前 评论

代码太杂乱了

3年前 评论

具体报什么错呢,这么看,这。。。。。

3年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!