Bash 脚本 Ubuntu mailx
当我的脚本创建新文件时,我想从 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
很可能您的 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).