【问题标题】:sSMTP no longer works - 'Invalid response: 501 5.5.4 HELO/EHLO argument MYEMAILADDRESS@gmail.com invalid, closing connection.'sSMTP 不再有效 - “无效响应:501 5.5.4 HELO/EHLO 参数 MYEMAILADDRESS@gmail.com 无效,正在关闭连接。”
【发布时间】:2016-07-19 08:08:57
【问题描述】:

正如标题/标签所说,我在 Linux 上为 PHP 服务器运行 sSMTP。

每当我尝试发送电子邮件时,我都会收到这些错误(不会出现在 PHP 中,仅出现在日志/“sudo service sendmail status”或“sudo service php5-fpm status”中)

来自 /var/log/mail.log

Mar 31 03:34:34 ip-172-31-22-38 sSMTP[2004]: Creating SSL connection to host
Mar 31 03:34:34 ip-172-31-22-38 sSMTP[2004]: Invalid response: 501 5.5.4 HELO/ELO argument MYEMAILADDRESS@gmail.com invalid, closing connection. v74sm9147441pfa.7- gsmtp (MYEMAILADDRESS@gmail.com)
Mar 31 03:34:34 ip-172-31-22-38 sSMTP[2004]: SSL connection using (null)
Mar 31 03:34:34 ip-172-31-22-38 sSMTP[2004]: Cannot open smtp.gmail.com:587

来自 /var/log/mail.err 和 mail.warn

Mar 31 03:34:10 ip-172-31-22-38 sSMTP[1997]: Cannot open smtp.gmail.com:587
Mar 31 03:34:34 ip-172-31-22-38 sSMTP[2004]: Invalid response: 501 5.5.4 HELO/EHLO argument MYEMAILADDRESS@gmail.com invalid, closing connection. v74sm9147441pfa.7 - gsmtp (MYEMAILADDRESS@gmail.com)
Mar 31 03:34:34 ip-172-31-22-38 sSMTP[2004]: Cannot open smtp.gmail.com:587

我的 /etc/ssmtp/ssmtp.conf

#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=MYEMAILADDRESS@gmail.com

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=smtp.gmail.com:587

# Where will the mail seem to come from?
#rewriteDomain=

# The full hostname
hostname=MYEMAILADDRESS@gmail.com

AuthUser=MYEMAILADDRESS@gmail.com
AuthPass=[removed]
UseSTARTTLS=YES
# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES

我的重新定义

root:MYEMAILADDRESS@gmail.com:smtp.gmail.com:587
localusername:MYEMAILADDRESS@gmail.com:smtp.gmail.com:587

【问题讨论】:

    标签: php linux email ssmtp


    【解决方案1】:

    经过多年的努力,我终于系好安全带并从 Arch Linux 的 wiki 文章中复制了用于 Gmail 和 SSMTP 的配置,并且最终成功了!伙计们,请务必三重检查您的配置!

    # The user that gets all the mails (UID < 1000, usually the admin)
    root=username@gmail.com
    
    # The mail server (where the mail is sent to), both port 465 or 587 should be acceptable
    # See also http://mail.google.com/support/bin/answer.py?answer=78799
    mailhub=smtp.gmail.com:587
    
    # The address where the mail appears to come from for user authentication.
    rewriteDomain=gmail.com
    
    # The full hostname
    hostname=localhost
    
    # Use SSL/TLS before starting negotiation
    UseTLS=Yes
    UseSTARTTLS=Yes
    
    # Username/Password
    AuthUser=username
    AuthPass=password
    
    # Email 'From header's can override the default domain?
    FromLineOverride=yes
    

    【讨论】:

      【解决方案2】:

      我的ssmtp.conf包含hostname=xxx@gmail.com,我改成hostname=localhost,问题就解决了。

      【讨论】:

      • 这也是我在 Java 中的解决方案。我不得不使用 props.put("mail.smtp.localhost", "localhost");
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-14
      • 1970-01-01
      • 2010-11-15
      相关资源
      最近更新 更多