Bash 脚本 Ubuntu mailx

发布于 2024-11-03 10:02:36 字数 469 浏览 3 评论 0原文

当我的脚本创建新文件时,我想从 bash 脚本发送电子邮件。

这是我到目前为止编写的代码:

SUBJECT="MyNotifier"
TO="[email protected]"

echo "mail body. Something happened here.... hope you get this!" | mailx -s "$SUBJECT" "$TO" 

重点是我没有收到任何错误消息,也没有收到邮件。

我只下载并安装了 mailx (使用 sudo apt-get 命令 - 对不起,我是菜鸟)

我根本没有配置它。

我做错了什么? 提前致谢

I want to send an email from a bash script when my script creates a new file.

This is the code I have written so far:

SUBJECT="MyNotifier"
TO="[email protected]"

echo "mail body. Something happened here.... hope you get this!" | mailx -s "$SUBJECT" "$TO" 

The point is I don't get any error messsages neither mails.

I have only downloaded and instaled mailx (with the sudo apt-get command - excuse me I am noob)

I haven't configured it at all.

What am I doing wrong?
Thanks in advance

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

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

发布评论

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

评论(1

梦年海沫深 2024-11-10 10:02:36

很可能您的 sendmail/exim 服务器未配置 - 因此电子邮件将被发送到 MTA(邮件传输代理),但仍留在队列中。如果您发出mailq命令,您应该会看到当前等待发送的邮件列表——如果队列中有邮件,那么您需要配置MTA,如果mailq中没有邮件然后你的电子邮件已发送,但可能被接收者丢弃(发生这种情况的原因有很多 - 你可以在谷歌上找到很多关于它的资源,但是一个非常常见的情况是如果你的发件人域没有映射回来到您发送电子邮件的 IP)。

Quite likely your sendmail/exim server isn't configured -- and as such the emails are being sent to the MTA (mail transport agent) but are left in the queue. If you issues a mailq command you should see the list of mails currently waiting to be sent -- if there are mails in the queue then you need to configure your MTA, if there are no mails in the mailq then your emails were sent but were probably discarded by the receiver (there are many reasons why this would happen -- and you can find lots of resources on google on it, however a very common one is if your sender domain doesn't map back to the ip you sent an email from).

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