简体   繁体   English

需要立即从邮件服务器获取电子邮件

[英]Need to fetch email from mail server immediately

I would like to "misuse" my email a little for a printing work.我想“滥用”我的电子邮件来进行印刷工作。 I have the whole setup ready but lack how to get my emails from my mailserver immediately as soon they arrive.我已经准备好了整个设置,但缺乏如何在邮件到达后立即从我的邮件服务器获取我的电子邮件。

In short I will get an email with a pdf attachment and need to print the attachement.简而言之,我会收到一封带有 pdf 附件的电子邮件,需要打印附件。 It works well with procmail, uudeview and a script to print pdf files.它适用于 procmail、uudeview 和用于打印 pdf 文件的脚本。 However I need to get download the email immediately which does not work yet.但是,我需要立即下载尚未工作的电子邮件。

I was looking in both fetchmail and getmail.我正在查看 fetchmail 和 getmail。 As far I understood fetchmail only works with a cronjob or daemon.据我所知,fetchmail 只适用于 cronjob 或守护进程。 I don't think that a cronjob should be run every 1 second.我认为不应每 1 秒运行一次 cronjob。

I would be very grateful to learn if this can be achieved with getmail or if other programs are availbale to do this.如果可以使用 getmail 或其他程序可以做到这一点,我将非常感激。

Perhaps update your .forward file to immediately forward the mail to procmail ?也许更新您的.forward文件以立即将邮件转发到procmail Or setup a rule to forward the mail to a system you control where you can do the processing immediately?或者设置规则将邮件转发到您控制的系统,您可以立即进行处理?

The .procmailrc setup on the incoming host would look like:传入主机上的.procmailrc设置如下所示:

"|IFS=' '&&p=/usr/local/bin/procmail&&test -f $p&&exec $p -f-||exit 75#some_string"

You could also use something like AWS SNS and Lambda to process the mail events.您还可以使用 AWS SNS 和 Lambda 之类的东西来处理邮件事件。

If you don't have those options, polling frequently would be your best bet.如果您没有这些选项,那么经常进行投票将是您最好的选择。 You can setup a script to poll every few seconds in a loop without generating much load on the server.您可以设置一个脚本以在循环中每隔几秒轮询一次,而不会在服务器上产生太多负载。 Typically your cron job would check if the script is running, and if not, relaunch it, otherwise do nothing.通常,您的 cron 作业会检查脚本是否正在运行,如果没有,则重新启动它,否则什么都不做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM