Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

SMTP Connection From (localhost) Closed By QUIT

Discussion in 'Security' started by MichaelEC, Jan 30, 2019.

  1. MichaelEC

    MichaelEC Member

    Joined:
    Jan 30, 2019
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Ireland
    cPanel Access Level:
    Website Owner
    Hi,

    I've been having some issues sending out automated emails through G-Mails SMTP settings. I have been back and forward with Google for quite some time now and they are very adamant that the setup is correct on their end (2-Step Auth, Less Secure Apps etc) along with my PHP file being setup correctly too (see screenshot, password removed and email changed).

    Attached to this thread is my PHP File setup along with errors from the exim_mainlog that show the connection being refused by localhost.

    PHP Setup:

    [removed - please attach images directly to the thread]

    exim_mainlog error (email changed & IP replaced with [xx.xx.xx.xx]:xxxxx):

    Code:
    2019-01-30 13:58:40 SMTP connection from [xx.xx.xx.xx]:xxxxx (TCP/IP connection count = 1)
    2019-01-30 13:58:42 dovecot_login authenticator failed for (localhost) [xx.xx.xx.xx]:xxxxx: 535 Incorrect authentication data ([email protected])
    2019-01-30 13:58:42 SMTP connection from (localhost) [xx.xx.xx.xx]:xxxxx closed by QUIT
    2019-01-30 13:58:42 SMTP connection from [127.0.0.1]:xxxxx (TCP/IP connection count = 1)
    2019-01-30 13:58:42 SMTP connection from (localhost) [127.0.0.1]:xxxxx closed by QUIT
    I'm completely stumped on what to do next - I've tried a lot of different methods as instructed by Google's Support but to no avail.

    This is the specific error message I get when running the PHP file in my browser;

    authentication failure [SMTP: Invalid response code received from server (code: 535, response: Incorrect authentication data)]
    I know the credentials I'm using are a proper email address (not an alias), it is under G-Suite and the password is the correct App Password.

    Something the Google Support member said which stands out was
    "I can tell for sure what what I see that you need to allow the server on your end/local host to make the authentication using the credentials of the added settings and not the one of the Cpanel or account added on the local host."
    If anyone has any idea on what to do next, that'd be great - please don't hesitate to ask me for more information.
     
    #1 MichaelEC, Jan 30, 2019
    Last edited by a moderator: Jan 30, 2019
  2. GOT

    GOT Get Proactive! PartnerNOC

    Joined:
    Apr 8, 2003
    Messages:
    1,485
    Likes Received:
    187
    Trophy Points:
    193
    Location:
    Chesapeake, VA
    cPanel Access Level:
    DataCenter Provider
    Your logs indicate you are trying to connect to localhost as its the localhost reporting the authentication failure.

    Are you running CSF? What is the setting for smtp_redirect set to if so?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    MichaelEC likes this.
  3. MichaelEC

    MichaelEC Member

    Joined:
    Jan 30, 2019
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Ireland
    cPanel Access Level:
    Website Owner
    Hi Got,

    We aren't running CSF as far as I can see (Under the Plugins section on WHM right?)
     
  4. MichaelEC

    MichaelEC Member

    Joined:
    Jan 30, 2019
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Ireland
    cPanel Access Level:
    Website Owner
    Just bumping this for more options!

    I'd assume something needs to be configured to stop trying to connect to localhost when running the PHP Mail script? Here's my PHP Script using Gmail SMTP;

    PHP:
    $host "smtp.gmail.com";
    $username "[email protected]";
    $password "redacted";
    $port "587";
    $to "[email protected]";
    $email_from "[email protected]";
    $email_subject "Email To All People" ;
    $email_body "Something Something Something" ;
    $email_address "[email protected]";

    $headers = array ('From' => $email_from'To' => $to'Subject' => $email_subject'Reply-To' => $email_address);
    $smtp Mail::factory('smtp', array ('host' => $host'port' => $port'auth' => true'username' => $username'password' => $password));
    $mail $smtp->send($to$headers$email_body);

    if (
    PEAR::isError($mail)) {
    echo(
    "<p>" $mail->getMessage() . "</p>");
    } else {
    echo(
    "<p>Message successfully sent!</p>");
    };
     
  5. cPanelLauren

    cPanelLauren Forums Analyst II Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    6,476
    Likes Received:
    507
    Trophy Points:
    263
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Hi @MichaelEC

    It looks like you're using local credentials for the mail
    you should be using your full gmail address or google apps address. If you're using the latter you need to ensure that the domain is put into
    Code:
    /etc/remotedomains
    and removed from
    Code:
    /etc/localdomains
    as it appears it's trying to authenticate with [email protected] locally.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    MichaelEC likes this.
  6. MichaelEC

    MichaelEC Member

    Joined:
    Jan 30, 2019
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Ireland
    cPanel Access Level:
    Website Owner
    Hi Lauren,

    Thanks for the response.

    [email protected] is actually just a placeholder, I'm using a Google Suite address which is [email protected]

    I've just had a look at localdomains and its only got two lines in it called server.company.io & XXXX.XXXX001.local

    In remotedomains there's also only one line called company.io

    (company is a placeholder for company name & XXXX replaces a string of characters)

    Not sure what I must do here!
     
    #6 MichaelEC, Feb 4, 2019
    Last edited: Feb 4, 2019
  7. cPanelLauren

    cPanelLauren Forums Analyst II Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    6,476
    Likes Received:
    507
    Trophy Points:
    263
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Hi @MichaelEC

    The question is about the domain you're using google apps with. If that domain is hosted on the server you need to add it to /etc/remotedomains or the server will continue to attempt to authenticate it locally which will continue to fail.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. MichaelEC

    MichaelEC Member

    Joined:
    Jan 30, 2019
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Ireland
    cPanel Access Level:
    Website Owner
    Hi @cPanelLauren,

    I get you, thanks.

    Unfortunately our domain is already in /etc/remotedomains - it's the only line in the file.
     
  9. Sunday Alabi

    Sunday Alabi Member

    Joined:
    Jan 29, 2019
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Nigeria
    cPanel Access Level:
    Root Administrator
    Currently also having issues with sending mails out. I am using Docker for magento. Sending mails from cpanel works, but sending mails from magento does not work with error message on whm `Rejected relay attempt: '127.0.0.1' From: '[email protected]mple.com' To: '[email protected]'`
     
  10. cPanelLauren

    cPanelLauren Forums Analyst II Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    6,476
    Likes Received:
    507
    Trophy Points:
    263
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Hi @MichaelEC


    Good that it's in remote domains just to be sure it's not also listed in localdomains correct? Without being able to see the configuration it's really hard to tell what's going wrong with the authentication. If you'd like to, please open a ticket using the link in my signature? Once open please reply with the Ticket ID here so that we can update this thread with the resolution once the ticket is resolved.


    Thanks!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  11. MichaelEC

    MichaelEC Member

    Joined:
    Jan 30, 2019
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Ireland
    cPanel Access Level:
    Website Owner
    Hi @cPanelLauren

    It is also listed in localdomains.

    I have an open ticket now, the number is 11333509.

    There are some suggestions from that ticket for me to try so I'll get those actioned sometime tomorrow or Friday, hopefully one of them works!
     
  12. cPanelLauren

    cPanelLauren Forums Analyst II Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    6,476
    Likes Received:
    507
    Trophy Points:
    263
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Hi @MichaelEC


    You also most likely need to remove it from /etc/localdomains or it's going to continue to attempt to authenticate locally. I'll check in on the ticket as well.

    Thanks!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice