SMTP sending an priority email

后端 未结 1 1628
故里飘歌
故里飘歌 2021-02-08 02:42

I am trying to use Python\'s smtplib to set the priority of an email to high. I have successfully used this library to send email, but am unsure how to get the prio

1条回答
  •  别跟我提以往
    2021-02-08 02:59

    Priority is just a matter of email content (to be exact, header content). See here.

    The next question would be how to put that into an email.

    That completely depends how you build that email. If you use the email module, you would do it this way:

    from email.Message import Message
    m = Message()
    m['From'] = 'me'
    m['To'] = 'you'
    m['X-Priority'] = '2'
    m['Subject'] = 'Urgent!'
    m.set_payload('Nothing.')
    

    and then use it with

    smtp.sendmail(from_addr, to_addr, m.as_string())
    

    0 讨论(0)
提交回复
热议问题