【问题标题】:unable to send email from unix shell scripting无法从 Unix shell 脚本发送电子邮件
【发布时间】:2016-05-05 10:42:29
【问题描述】:

我正在尝试使用 'sendmail' 命令从 unix shell 脚本发送电子邮件警报,我的代码如下:

recipients="rajkumar.soundararajan@visy.com.au,basha.kather@gmail.com,katherbasha.amanullah@techmahindra.com"
subject="DB Blocking session found!"
from="rajkumar.soundararajan@visy.com.au"

message_txt="Hi all!\n There are DB blocking session found in DB"

#echo -e "\n${output}"
if [ ! -z "$output" -a "$output" != " " ]; then

        echo "blocking session found in db!!"

#echo "DB blocking session found" | mail -s "DB BLOCKING!!" katherbasha.amanullah@techmahindra.com

#echo "DB blocking session found" | mail -s "DB BLOCKING!!" basha.kather@gmail.com

/usr/sbin/sendmail "$recipients" << EOF
subject:$subject
from:$from
$message_txt
EOF
fi

执行上述代码时,我得到以下输出,但没有向任何人发送电子邮件:

va_manh@manhdevdb:/home/oracle/scripts$ sh db_blocking_session.sh 在 db 中发现阻塞会话!!

我在 /var/log/maillog 中找到以下行:

1 月 28 日 17:52:03 manhdevdb postfix/pickup[7539]: 176D013C0BD: uid=800 从= Jan 28 17:52:03 manhdevdb 后缀/清理[10861]: 176D013C0BD: message-id= 1 月 28 日 17:52:03 manhdevdb postfix/qmgr[3591]: 176D013C0BD: from=, size=406, nrcpt=3 (队列 活动)1 月 28 日 17:52:33 manhdevdb postfix/smtp[10865]:连接到 cluster6.us.messagelabs.com[216.82.242.36]:连接超时(端口 25) 1 月 28 日 17:52:33 manhdevdb postfix/smtp[10863]: 连接到 gmail-smtp-in.l.google.com[64.233.187.26]:连接超时(端口 25) 1 月 28 日 17:52:33 manhdevdb postfix/smtp[10864]: 连接到 mxmeg6.techmahindra.com[203.143.186.187]:连接超时(端口 25) 1 月 28 日 17:54:33 manhdevdb 后缀/smtp[10863]: 176D013C0BD: to=,relay=none,delay=150,status=deferred (连接到 alt4.gmail-smtp-in.l.google.com[173.1 94.219.26]:连接超时)1 月 28 日 17:56:03 manhdevdb postfix/smtp[10864]: 176D013C0BD: to=, 中继=无, 延迟=240, 状态=延迟(连接到 mxmeg2.techmahindra.com[119.151.17.92]: 连接超时)1 月 28 日 17:57:08 manhdevdb postfix/smtp[10925]: 9EF5513C0A3:到=,继电器=无, 延迟=75276,状态=延迟(连接到 cluster6a.us.messagelab s.com[85.158.139.103]:连接超时)

请告诉我造成这种情况的根本原因?

【问题讨论】:

    标签: sendmail


    【解决方案1】:

    连接超时可能意味着您的托管服务提供商阻止 TCP/25 出站,通常是为了防止垃圾邮件。您可以考虑通过 Amazon SES、MailGun、SendGrid 等受信任的提供商进行中继。不幸的是,如今运行您自己的邮件服务器是一场持久战。

    【讨论】:

    • 谢谢伙计。我已经与基础设施团队讨论过这个问题。他们说有 SMTP 服务器,只有我们可以通过它发送电子邮件。有谁知道如何通过 sendmail 命令使用 smtp 详细信息?
    猜你喜欢
    • 2010-12-19
    • 2016-11-03
    • 1970-01-01
    • 2011-04-19
    • 1970-01-01
    • 1970-01-01
    • 2014-10-25
    • 2021-03-16
    • 2011-09-16
    相关资源
    最近更新 更多