带有名称的crontab邮寄

发布于 2025-01-26 09:03:13 字数 929 浏览 2 评论 0 原文

我的crontab设置为波纹管:

MAILFROM=name <[email protected]>
[email protected]
* * * * * root echo "Message here"

因此,我会收到错误:

May  4 14:31:01 ubuntu22 CRON[71554]: (root) UNSAFE MAIL (name <[email protected]>)

消息是默认发送的: cron daemon&root@ubuntu22&gt;

如果我设置 [email&nbsp; procented]

有没有一种方法可以自定义邮件名称,而不仅仅是电子邮件?

my crontab is set bellow:

MAILFROM=name <[email protected]>
[email protected]
* * * * * root echo "Message here"

so I get the error:

May  4 14:31:01 ubuntu22 CRON[71554]: (root) UNSAFE MAIL (name <[email protected]>)

the message is sent with default From: Cron Daemon <root@ubuntu22>

if I set [email protected] it works fine but have no name.

Is there a way to custom MAILFROM with mail name and not email only?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

萌面超妹 2025-02-02 09:03:13

您缺少围绕邮寄值的报价。
如果它具有该值的空间,则需要引号。

MAILFROM="name <[email protected]>"

未测试。

You're missing quotes around the MAILFROM value.
If it has a space in the value, it needs the quotes.

MAILFROM="name <[email protected]>"

Not tested.

旧瑾黎汐 2025-02-02 09:03:13

通过编写shell脚本而不是sendmail,并判断和修改接收到的电子邮件内容,然后将参数转发到原始的bsendmail以拦截和修改它。

mv /usr/sbin/sendmail /usr/sbin/bsendmail ; vim /usr/sbin/sendmail

#!/bin/bash
#/usr/sbin/sendmail

text=$(cat)
echo $text|grep -q 'Cron Daemon'&&(
  echo -e "$text"|sed '1c From: Service Notification <[email protected]>' |sed '3c Subject: Scheduled Task Log' | /usr/sbin/bsendmail $*) || (
  echo -e "$text"| /usr/sbin/bsendmail $*)
exit 0;

chmod 777 /usr/sbin/sendmail

By writing a shell script instead of sendmail, and judging and modifying the received email content, and forwarding the parameters to the original bsendmail to intercept and modify it.

mv /usr/sbin/sendmail /usr/sbin/bsendmail ; vim /usr/sbin/sendmail

#!/bin/bash
#/usr/sbin/sendmail

text=$(cat)
echo $text|grep -q 'Cron Daemon'&&(
  echo -e "$text"|sed '1c From: Service Notification <[email protected]>' |sed '3c Subject: Scheduled Task Log' | /usr/sbin/bsendmail $*) || (
  echo -e "$text"| /usr/sbin/bsendmail $*)
exit 0;

chmod 777 /usr/sbin/sendmail
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文