通过IMAP添加自定义RFC822标头? [英] add a custom RFC822 header via IMAP?

查看:278
本文介绍了通过IMAP添加自定义RFC822标头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用imaplib在IMAP服务器上的消息中添加自定义RFC822标头的简单方法?

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

我正在编写一个基于python的程序来过滤我的IMAP邮件存储.当我使用Procmail进行此操作时,我可以选择添加标题.但是,似乎没有办法通过Python imap实现来做到这一点.

I am writing a python-based 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.

要将myflag添加到邮件中,您可以使用

To add myflag to the message you can use

STORE number +FLAGS (myflag) 

搜索:

SEARCH KEYWORD myflag

请记住,某些服务器不允许自定义标志.

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

这篇关于通过IMAP添加自定义RFC822标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆