开发者

add a custom RFC822 header via IMAP?

Is there an easy way to add a custom RFC822 header to a message on an IMAP server with imaplib?

I am writing a python-base开发者_运维百科d program that filters my IMAP mail store. When I did this with Procmail I had the option of adding headers. But there doesn't seem to be a way to do that with the Python imap implementation.

Specifically, I want to add a custom header like:

X-VY32-STATUS: Very Cool

So that it appears in the mail headers:

 To: vy32@stackoverflow.com
 From: Yo@mama.com
 Subject: Test Message
 X-VY32-STATUS: Very Cool

 The regular message is down here.


Better option would be to use custom server flags called keywords.

A keyword is defined by the server implementation. Keywords do not begin with "\". Servers MAY permit the client to define new keywords in the mailbox.

To add myflag to the message you can use

STORE number +FLAGS (myflag) 

to search:

SEARCH KEYWORD myflag

Bear in mind that some servers don't allow custom flags.


I don't think RFC 2060 allows the edit of received mail headers. If you want to edit the mail response header this can be done with the email package.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜