python发送附件到kindle电子书 接收不到
PHPz
PHPz 2017-04-17 16:35:08
0
3
623

代码如下

def send_attachment_kd(filename,toName,fromName,username,password):
    msg = MIMEMultipart()
    msg['Subject'] = 'convert'
    msg['From'] = "username"+"<"+fromName+">"
    msg['To'] = toName
    part = MIMEBase('application', "octet-stream")
    #fpath=os.path.join(KINDLE_DIR,filename)
    filename_txt=filename+".txt"
    #print filename_txt.decode('utf-8'
    filecontent=open(filename_txt.decode('utf-8'),'r').read()
    part.set_payload(filecontent)
    Encoders.encode_base64(part)
    part.add_header('Content-Disposition', 'attachment; filename="Book.txt"')
    msg.attach(part)
    try:
        server=smtplib.SMTP()
        server.connect('smtp.qq.com')
        server.login(username,password)
        server.sendmail(msg['From'],toName,msg.as_string())
        server.quit()
        print "Send successfully"
    except Exception,e:
        print "Error"
        print str(e)

在qq邮箱里面的发送箱可以看到我发送的邮件以及附件,没有乱码和不对的地方,可是我的kindle却一直都没有收到推送,请问有人写过相关的代码吗??
经过测试,发现是qq邮箱的问题。

全部源码链接:
python推送知乎文章到kindle

gtihub: https://github.com/Rockyzsu/zhihuToKindle

PHPz
PHPz

学习是最好的投资!

reply all(3)
黄舟

Has your test email address been added to the list on Amazon?

黄舟

After testing, it was found that it was a problem with the qq mailbox.

Full source code link: (regularly updated with new features)
http://30daydo.com/article/7

gtihub: https://github.com/Rockyzsu/z...

黄舟

Brother, please tell me, I developed it using Node. It's probably a problem of getting stuck in the mailbox and sending attachments that don't exist. Also cut the mailbox. I didn't run this complete version of yours. But I looked at the general idea and I have the same idea. I don’t know how you solve the attachment problem.
Let me tell you my situation.
1. The sending email address is certified.
2. Change to NetEase 163
3. If you send the same program to a small account, you will receive the attachment normally.
4. The cloud link is not saved when the mailbox storage has been set up
5. The content sent is a mobi file of less than 1MB downloaded before, which is guaranteed to be open and read.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template