Python: “subject” not shown when sending email using smtplib module

后端 未结 7 2117

I am successfully able to send email using the smtplib module. But when the emial is sent, it does not include the subject in the email sent.

import smtplib
         


        
7条回答
  •  天涯浪人
    2020-12-04 21:44

    Attach it as a header:

    message = 'Subject: {}\n\n{}'.format(SUBJECT, TEXT)
    

    and then:

    server = smtplib.SMTP(SERVER)
    server.sendmail(FROM, TO, message)
    server.quit()
    

    Also consider using standard Python module email - it will help you a lot while composing emails.

提交回复
热议问题