Procmail自动创建新文件夹以存储来自新发件人的电子邮件 [英] Procmail to automatically make new folders to store emails from new senders

查看:103
本文介绍了Procmail自动创建新文件夹以存储来自新发件人的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习如何使用procmail,但是到现在为止,我什至不确定它是否是我要执行的操作的正确工具.

I am learning how to use procmail but at this point, I am not even sure it's the right tool for what I am trying to do.

到目前为止,我已经设法获取fetchmail来从Google IMAP帐户检索电子邮件,并获取procmail来将这些电子邮件过滤到我先前创建的本地文件夹中.

So far, I have managed to get fetchmail to retrieve emails from a Google IMAP account and procmail to filter those emails into local folders I had previously created.

我想知道,是否有一种方法可以使procmail在检索来自新发件人的电子邮件时自动在本地创建一个新文件夹,并将该电子邮件存储到该文件夹​​中.

I am wondering though whether there is a way to get procmail to automatically create a new folder locally when an email from a new sender is being retrieved and to store that email into that folder.

到目前为止,我只发现了一个网站,该网站描述了procmail可能会自动创建用于邮件列表的文件夹的方法,但是使用我不知道其含义的字符却使方法变得有些疯狂,而且procproc官方网站似乎无法访问.

So far, I have only found a website that describes the possibility of procmail creating automatically folders for mailing lists, but the recipe is something crazy using characters which I have no idea the meaning of, furthermore the official procmail website seems unreachable.

请您能帮忙吗?谢谢.

推荐答案

目前尚不清楚您希望该文件夹被调用的内容以及所使用的邮箱格式;但是假设使用发件人的电子邮件终端命名的maildir文件夹,请尝试

It's not clear what you expect the folder to be called, and what mailbox format you're using; but assuming maildir folders named by the sender's email terminus, try

Who=`formail -rtzxTo:`
:0
* ? mkdir -p "$Who"
$Who/

对于mbox文件夹,您根本不需要目录检查,因为该文件夹只是一个文本文件,您可以从文件夹名称中删除最后的斜杠. Mbox需要锁定,因此请在零后面添加第二个冒号.

For an mbox folder, you don't need the directory check at all, because the folder is just a single text file, and you'd drop the final slash from the folder name. Mbox needs locking, so add a second colon after the zero.

Who=`formail -rtzxTo:`
:0:
$Who

获取formail来创建回复,然后提取所生成的回复的To:标头是一种标准的方法,但这种方法不太明显,它仅获取输入消息发件人的电子邮件终端.

Getting formail to create a reply and then extracting the To: header of the generated reply is a standard but slightly unobvious way to obtain just the email terminus for the sender of the input message.

如果dir尚不存在,则创建dir,否则为无害操作.

The shell snippet mkdir -p dir creates dir if it doesn't already exist, and is a harmless no-op otherwise.

这篇关于Procmail自动创建新文件夹以存储来自新发件人的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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