加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

unix – 在接收电子邮件时触发shell脚本

发布时间:2020-12-15 21:20:49 所属栏目:安全 来源:网络整理
导读:我们如何通过特定主题的电子邮件在unix服务器上触发 shell脚本? 解决方法 procmail允许您对传入的邮件执行操作,包括过滤和启动外部命令. 一些有用的链接: 一般procmail文件:http://pm-doc.sourceforge.net/doc/ 以procmail规则启动shell命令:http://pork
我们如何通过特定主题的电子邮件在unix服务器上触发 shell脚本?

解决方法

procmail允许您对传入的邮件执行操作,包括过滤和启动外部命令.

一些有用的链接:

>一般procmail文件:http://pm-doc.sourceforge.net/doc/
>以procmail规则启动shell命令:http://porkmail.org/era/procmail/mini-faq.html#rtfm

如果链接断开,这是second point from above的链接:

Q: How can I run an arbitrary Perl or shell script on all or selected
incoming mail?

A: Install Procmail. Read the manual pages (there are several). Thank
you.

:0 * conditions,if any | your-script-here

The conditions,in their simplest form,are regular expressions to
match against the header of each incoming mail message. Correction:
Even simpler,you can leave out the condition lines completely if you
want to do your action (in this case,run a shell script)
unconditionally.

More-complicated conditions can also be exit codes of other shell
scripts or programs,or tests against the full body of the message,or
against Procmail variables (Procmail’s variables are also exported to
the environment of subprocesses,so they are essentially environment
variables. There are details about this later in this FAQ.)

Actions can also be to save the message to a folder (appended to a
Unix mailbox file,or written to a new file in a directory) or to
forward the message to one or more other addresses. Finally,the
action can be a nested block of more “recipes,” as these
condition-action mappings are called in Procmail jargon,to try if the
outer condition is met. The procmailrc(5) manual page has the full
scoop.

Obviously,you are not restricted to Perl or shell scripts. Anything you can run from a Unix command prompt can be run from Procmail,in principle,although running interactive programs doesn’t usually make much sense.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读