Laravel - Failed to authenticate on SMTP server with .. using 2 possible authenticators - laravel

I saw this questions were asked many times. I tried many of them and nothing working. I am using laravel and mailgun api to send email.
I am geting this error Failed to authenticate on SMTP server with username "postmaster#noreplay.padelmatch.se" using 2 possible authenticators and also in my dedicated server log I get
2018-05-30 13:37:32 dovecot_login authenticator failed for
(domain.com) [198.20.114.174]:40412: 535 Incorrect authentication
data (set_id=email#sub.subdomain.com)
2018-05-30 13:37:38 SMTP connection from (domain.com)
[198.20.114.174]:40412 lost
I also created a email account with same name (email#sub.subdomain.com) but still doesn't work.
In my .env file I have a set up like this
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=25
MAIL_USERNAME=email#sub.domain.com
MAIL_PASSWORD=xxxxxxx
MAILGUN_SECRET=xxxxxxx
MAILGUN_DOMAIN=sub.domain.com
MAIL_ENCRYPTION=null
Any idea how can I solve it?
Thank you.

I solved it. Actually it was a stupid thing. Since I was using mailgun so I don't need to use smpt as it is causing the issue. So in mail driver, I used MAIL_DRIVER=mailgun and that's the solution for my case :). Hope it helps some lonely googler....

Related

Gmail smtp not working with only one email

I am using gmail smtp in my laravel, It was working fine till yesterday but it suddenly stopped, I am getting this error
Failed to authenticate on SMTP server with username "email#gmail.com" using 3 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "535", with message "535-5.7.8 Username and Password not accepted
Less secure apps was already on so i added 2 factor auth and created an app password but still not working, I created a test email and it worked fine, why is not working with my first email
This is my setting in env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=email#gmail.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
MAIL_EMAIL_ADDRESS=email#gmail.com
I also tried by adding double quotes, but still not wokring,
Can anyone please help
After the removal of less secure apps. You can no longer connect to googles smtp server using the actual password of the users gmail account.
YOu have two options.
enable 2fa on the google account and create an apps password. The apps password can then be used in place of the password in your code.
Switch to using Xoauth2.

"Failed to authenticate on SMTP server" after more than 100 emails

I'm trying to send about 500 emails with Laravel, my provider is Gmail.
The first 150 emails (more or less) are sent correctly, but after I receive this error:
"Failed to authenticate on SMTP server with username "XXXXXXX" using 3 possible authenticators. Authenticator LOGIN returned Expected response code 250 but got an empty response. Authenticator PLAIN returned Expected response code 250 but got an empty response. Authenticator XOAUTH2 returned Expected response code 250 but got an empty response."
My .env is
MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_ENCRYPTION=ssl
MAIL_USERNAME=...
MAIL_PASSWORD=...
I also tried to wait for about 5 seconds between each email, but it doesn't work.
Anyone knows how I can handle this?
Thank you
Try to use the next settings:
MAIL_PORT=465
MAIL_ENCRYPTION=ssl
Enable 2FA in your Google account and create an app password.
Use it in MAIL_PASSWORD
I had a similar problem, and here is how I solved it.
the Google mail service may have blocked emails from being sent from your app. Google surely viewed this as a security threat. you should definitely receive a security alert in your mailbox.
You just have to admit that it was you who tried to access the account or just change your gmail password. after that please change the info in the .env file and i think it will work.
try to change your password on gmail
and also in your .env file

send email in laravel by gmail smtp server

I want to use Gmail to send emails through Laravel.
When I apply through localhost, the email is sent correctly.
But it gives the following error on the server and the email is not sent.
local.ERROR: Swift_TransportException: Connection could not be established with host smtp.gmail.com $:stream_socket_client(): unable to connect to tcp://smtp.gmail.com:587 (Connection timed out)
Hello I had the same problem probably your solution is like that, because this helps me to resolved my issue
Create a custom app in you Gmail security settings.
Log-in into Gmail with your account
Navigate to https://security.google.com/settings/security/apppasswords
In 'select app' choose 'custom', give it an arbitrary name and press generate
It will give you 16 chars token.`
Use the token as password in combination with your full Gmail account and two factor authentication will not be required.
Note: The link in step 2 will work only if you have 2-factor-authentication enabled.
For Refference: link
use mail trap for testing
link https://mailtrap.io/ where you get your all smtp credential and put in .env file

Expected response code 235 but got code 535 laravel send email using office365 smtp

I want to send email using my office365 smtp credentials in laravel application. i have make changes in my .env file for email settings as below:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
MAIL_USERNAME=info#***.com
MAIL_PASSWORD=*******
MAIL_ENCRYPTION=tls
while i am trying to send email i got error like
Failed to authenticate on SMTP server with username \"info#omoyyc.com\" using 2 possible authenticators. Authenticator LOGIN returned Swift_TransportException: Expected response code 235 but got code \"535\", with message \"535 Incorrect authentication data\r\n\"
my email sending code is as below
Mail::send(array(), array(), function ($m) use ($templatecontent) {
$m->from('customerservice#****.com', 'TEST');
$m->to('test#gmail.com', 'Test')
->subject($templatecontent['subject'])
->setBody($templatecontent['content'], 'text/html');
});
Can anyone guide me what is the issue and how to solve this issue?
I don't know if the cause is the same as OP, but I got the same error. I fixed it by enclosing the password with double quotes.
I'm assuming that the parsing fails when the password contains special characters.
I had the same issue.
I used Gmail SMTP, with less secure apps enabled & 2-factor auth disabled, and nothing worked. And surprisingly as #jessij mentioned, setting the password in double-quotes worked.
Do below in .env file:
Replace: MAIL_PASSWORD=yourpassword
With: MAIL_PASSWORD="yourpassword"
my problem is same dude, but my problem has been solved to try it :
Go to https://myaccount.google.com/security#connectedapps
Take a look at Security menu -> Apps with account access menu.
You must turn the option "Allow less secure apps" ON.
If you already followed this step, try again your project. and if it still doesn't work, please continue this steps :
Visit https://accounts.google.com/UnlockCaptcha
Click continue button
Good Luck dude!
If your password contains special characters like "john##3398", put this in " ". Then clear your php artisan cache using
php artisan config:cache
Then start your php artisan serve.

smtp relay - g suite - gmail with custom domain email

I have a created an account from G Suite - test#my-domain.com. I have enabled 2-factor authentication and created app-specific password too.
Also, I read that I need to allow less secure apps but I can't as I did 2-factor auth.
Also, my domain is working on ssl certificate from LetsEncrypt.
This is my config file:
MAIL_DRIVER=smtp
MAIL_HOST=smtp-relay.gmail.com // or smtp.gmail.com
MAIL_PORT=465 // or 587
MAIL_USERNAME=test#my-domain.com
MAIL_PASSWORD=unkdgapoymfgcwxu << app specific password
MAIL_ENCRYPTION=ssl // or tls
MAIL_FROM_ADDRESS=test#my-domain.com
MAIL_FROM_NAME=Support
From admin dashboard, I ticked the 'SMTP-relay' setting:
Allowed senders: Only addresses in my domains
Only accept mail from the specified IP addresses: No
Require SMTP Authentication: Yes
Require TLS encryption: No
...and I also added 'Support' as 'Send mail as' input in Gmail Settings > Accounts
I am stuck and keep getting error:
Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?p=BadCredentials i203sm350313wmf.0 - gsmtp
I have tried all different combinations but I couldn't move any further than this error. What am I doing wrong?
I know there are many questions related this topic but I couldn't find anything working for specifically G Suite - with custom domain
I am not sure if G Suite is any different than Gmail, but when I tried with personal gmail account it works. So, if I try for my personal gmail with this config, it works:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=me#gmail.com
MAIL_PASSWORD=utrpokvkvwluwujx < one time password
MAIL_ENCRYPTION=ssl
I've faced similar problem and got it solved by disabling 2FA, then enabling access for less secure apps. You have to use your normal password afterwards.
While I'm not very happy with it securitywise, at least it's something that works.
This single step worked for me... No 2-step verification. As I had created a dummy account for my local development, so I was OK with this setting. Make sure you only do this if your account contains NO personal or any critical data. This is just another way of tackling this error and NOT secure.
I turned ON the setting to alow less secured apps to be allowed access. Form here : https://myaccount.google.com/lesssecureapps

Resources