【问题标题】:Using sendmail from command line [closed]从命令行使用 sendmail [关闭]
【发布时间】:2013-05-03 16:04:42
【问题描述】:

我正在尝试编写一个 bash 脚本,由一个 cron 任务运行,它会在某些情况下向我发送一封电子邮件。

为了尝试让 sendmail 与我的 Sendgrid SMTP 设置一起使用,我编辑了 /etc/postfix/main.cf 文件,其中包含以下内容:

smtp_sasl_password_maps = static:<username>:<password>
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = may
smtp_tls_security_level=encrypt
header_size_limit = 4096000
relayhost = [smtp.sendgrid.net]:587

我使用 sudo /etc/init.d/postfix restart

重新启动了 postfix

并尝试使用以下命令从命令行发送电子邮件:

发送邮件 my@email.com/email.txt

这会产生以下输出:

您在 /var/mail/ubuntu 中有新邮件

为什么 sendgrid 不使用我在 main.cf 中指定的 Sendgrid SMTP 详细信息与我的电子邮件一起发送?

请注意,这个问题仅与 sendmail 有关,我不想安装其他 SMTP 客户端和应用程序,它需要按原样工作。

【问题讨论】:

    标签: email cron sendmail


    【解决方案1】:

    我的 Postfix 配置错误。我需要使用以下内容:

    smtp_sasl_auth_enable = yes
    smtp_sasl_password_maps = static:<username>:<password>
    smtp_sasl_security_options = noanonymous
    smtp_tls_security_level = may
    header_size_limit = 4096000
    relayhost = [smtp.sendgrid.net]:587
    

    通过 bash 脚本发送邮件如下:

    sendmail email@address.com <<EOF
    subject:This is a test
    from:from@address.com
    Body message here...
    EOF
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-28
      • 1970-01-01
      • 1970-01-01
      • 2016-09-24
      • 2013-04-12
      • 2019-01-10
      • 1970-01-01
      • 2015-05-12
      相关资源
      最近更新 更多