Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-20982

Fix: Mails sent via command line fail due to EHLO/HELO being "localhost"

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.7.12
    • Fix Version/s: 4.7.25
    • Component/s: CiviMail
    • Labels:
    • Versioning Impact:
      Patch (backwards-compatible bug fixes)
    • Documentation Required?:
      None
    • Funding Source:
      Contributed Code
    • Verified?:
      No
    • Overview:
      Hide
      Improve the likelihood CiviMails will be delivered. When connecting to some SMTP servers, CiviMail will identify itself in a way that (a) may prevent the server verifying the sender and (b) resembles a spammer. This is a simple fix to improve the way CiviMail identifies itself.
      Show
      Improve the likelihood CiviMails will be delivered. When connecting to some SMTP servers, CiviMail will identify itself in a way that (a) may prevent the server verifying the sender and (b) resembles a spammer. This is a simple fix to improve the way CiviMail identifies itself.
    • How it works currently:
      Hide
      1. Configure emails to be sent using SMTP
      2. Send a CiviMail using the command line
      3. The mailer will identify itself to the SMTP server as "EHLO localhost"
      4. In some cases the SMTP server will reject the email
      Show
      1. Configure emails to be sent using SMTP 2. Send a CiviMail using the command line 3. The mailer will identify itself to the SMTP server as "EHLO localhost" 4. In some cases the SMTP server will reject the email
    • How it should work:
      Hide
      1. Configure emails to be sent using SMTP
      2. Send a CiviMail using the command line
      3. The mailer will identify itself to the SMTP server as "EHLO example.com"
      4. The SMTP server will accept the email
      Show
      1. Configure emails to be sent using SMTP 2. Send a CiviMail using the command line 3. The mailer will identify itself to the SMTP server as "EHLO example.com" 4. The SMTP server will accept the email

      Description

      This problem relates to the following code in CRM_Utils_Mail::createMailer() ...

            $params['localhost'] = CRM_Utils_Array::value('SERVER_NAME', $_SERVER, 'localhost');

       When being executed by the CLI, 'SERVER_NAME' is unset so the mailer will identify itself as "localhost" in SMTP EHLO or HELO commands.

      In our experience using G Suite for Non-profits, Google rejects these emails. The problem rights itself when we replace "localhost" with our host name.

      I'll supply a patch that gets the host from CIVICRM_UF_BASEURL if SERVER_NAME is unset.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              ken Ken West
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: