SMTP Connection From (localhost) Closed By QUIT
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):
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.
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 (set_id=test@test.com)
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 QUITI'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.
-
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? 0 -
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?
Hi Got, We aren't running CSF as far as I can see (Under the Plugins section on WHM right?)0 -
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 = "test@test.com"; $password = "redacted"; $port = "587"; $to = "test@test.com"; $email_from = "test@test.como"; $email_subject = "Email To All People" ; $email_body = "Something Something Something" ; $email_address = "test@test.com"; $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(" " . $mail->getMessage() . "
"); } else { echo("Message successfully sent!
"); };[/PHP]0 -
Hi @MichaelEC It looks like you're using local credentials for the mail [QUOTE]test@test.com
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/etc/remotedomains
and removed from/etc/localdomains
as it appears it's trying to authenticate with test@test.com locally.0 -
Hi Lauren, Thanks for the response. test@test.com is actually just a placeholder, I'm using a Google Suite address which is info@company.io 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! 0 -
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. 0 -
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.
Hi @cPanelLauren, I get you, thanks. Unfortunately our domain is already in /etc/remotedomains - it's the only line in the file.0 -
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: 'emailfrom@example.com' To: 'emailto@example.com'` 0 -
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! 0 -
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! 0 -
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! 0 -
I had the same error. For reference and others, here are the steps how I resolved it: 1. Need to allow less secure apps in your google admin (https://myaccount.google.com/u/5/apppasswords) to bypass Google security concerns and 2-factor auth issues. You must use the newly created app specific password instead of your regular login gmail $password. 3. Try to send mail, which is likely to be blocked by a Captcha. Clear the captcha (SMTP relay: Route outgoing non-Gmail messages through Google - Google Workspace Admin Help). 0
Please sign in to leave a comment.
Comments
12 comments