I am trying to setup emails in my Laravel aplication, I have my env file something like this:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=noreply#xxx.com
MAIL_PASSWORD=xxx
MAIL_ENCRYPTION=tls
I tried according to the answer given in this question Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted
I followed the steps, enabled 2 step verification, then created app password and configured my .env file
Finally I did php artisan config:cache
Failed to authenticate on SMTP server with username "noreply#xxx.com" using 3 possible authenticators. Authenticator LOGIN returned Swift_TransportException: Expected response code 235 but got code "534", with message "534-5.7.14
Please help me out with this. Thanks.
Steps to configure Gmail/Google SMTP with Laravel
.env file setup
MAIL_DRIVER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_USERNAME=GMAIL_USERNAME
MAIL_PASSWORD=GMAIL_PASSWORD
MAIL_ENCRYPTION=ssl
Allow Less Secure Apps
Go to Google Accounts > Security > Allow less secure apps.
Allow new device, either allow new signing from google review notification from your mobile device or if that doesn't work. Login with the same gmail id and open below link, it will enable you to allow the recent login attempt. (only required once to authenticate our Laravel app)
https://www.google.com/accounts/DisplayUnlockCaptcha
P.S. - If you have 2 step verification enabled, then Create app password and use that instead of GMAIL_PASSWORD
Reference - https://support.google.com/mail/answer/7126229
I had the same problem. It was the Captcha link that fixed the issue, even though I don't use it. It seems there is an additional step to allow new devices to open the gmail account.
https://support.google.com/mail/answer/7126229?visit_id=636865986363810933-1186759849&rd=1#cantsignin
I had already set up this below beforehand
Allow less secure apps: If you don't use 2-Step Verification, you might need to allow less secure apps to access your account.
Need to create new less secure gmail account for configuration Email. your email should not use in more than 3 projects.
If you can't solve this with all the answers above, go to your account setting https://myaccount.google.com/security turn on two-step verification and generate an app password, this way will definitely work.
You can use MAIL_PASSWORD=yourapppassword instead of gmail password
like
MAIL_DRIVER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_USERNAME=GMAIL_USERNAME
MAIL_PASSWORD=APP_PASSWORD
MAIL_ENCRYPTION=ssl
If u are not created. Create a new one
go to Google Account ,then security then u will app password.
use app password instead of gmail password
go to gmail settings/security
In Signing in to Google section
open app password and generate password
Related
Hi i am trying to send emails in laravel.But when trying to send it is genrating following error and mails are not sending. But everything worked fine in localhost without any problems.
Failed to authenticate on SMTP server with username "lifeloveandotherthings94#gmail.com" using 2 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "535", with message "535 Incorrect authentication data
". Authenticator PLAIN returned Expected response code 235 but got code "535", with message "535 Incorrect authentication data"
Following is my code in .env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_USERNAME=myemail#gmail.com
MAIL_PASSWORD=MyEmailPassword
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=noreply#lifelove.com
MAIL_FROM_NAME='LifeLoveAndOtherThings'
I havent added additonal code in config/mail.php
'stream' => [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true,
],
],
I havent changed or added my emails in config/mail.php.I have set it up only in .env file. What is the issue here.
I have a similar error and I enquoted my password and it worked like charm.
MAIL_PASSWORD="YourEmailPassword"
If the problem still continues try using username, password and port number in double quotes.
If you are using your personal Gmail account then follow these steps :
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 have already followed these steps, try re-starting your project. and if it still doesn't work, please continue these steps :
Visit https://accounts.google.com/UnlockCaptcha
Click continue button
Good luck!
For me, this was my problem
Authenticator XOAUTH2 returned Expected response code 235 but got code "535", with message "535 5.7.3 Authentication unsuccessful
This happened suddenly after a few month in production (before it worked perfectly). After having visited other post with similar question, none of which worked, the solution that I found was...
to change the password and WAIT SOME TIME in order to be effective.
I know, I know
I think that the password on outlook was expired after some time. The config was the same.
The way you can do if you are using cpanel/whm :
in WHM search TweakSetting in Server Configuration
In Tweak Setting Page click on the Mail tab
Search smtp in Mail tab
search for Restrict outgoing SMTP to root, exim, and mailman (FKA SMTP Tweak)
change the default on to off
Save the new setting
Hope this will help you :)
it was solved in my case by disabling the SMTP restriction option from WHM.
Nothing posted above worked for me.
The bug was in password. It needed to be put in apostrophe.
Try to solve it using either of these:
Your .env should be something like this..
This if for domain email
MAIL_DRIVER=mail
MAIL_HOST=mail.yourdomain.com
MAIL_PORT=465
MAIL_USERNAME=yourdomain.com
MAIL_PASSWORD="password"
MAIL_ENCRYPTION=ssl
MAIL_FROM_NAME="${APP_NAME}"
This if for Gmail email
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=youremail#gmail.com
MAIL_PASSWORD="yourPassword"
MAIL_ENCRYPTION=ssl
MAIL_FROM_NAME="${APP_NAME}"
The second option
Change
MAIL_ENCRYPTION=ssl
to
MAIL_ENCRYPTION=tsl
Or vice versa
The 3rd option
Allow less secure apps in you email
I hope it solve your problem
I need send email with laravel to gmail but it's showing the below error:
Error:
Expected response code 250 but got code "530", with message "530 5.7.0
Must issue a STARTTLS command first. 127sm105612220wmm.45 - gsmtp "
First login to your Gmail account and under My account > Sign In And Security > Sign In to google, enable two step verification, then you can generate app password, and you can use that app password in .env file.
Your .env a file will then look something like this:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myemail#gmail.com
MAIL_PASSWORD=apppassword
MAIL_ENCRYPTION=tls
Don't forget to run php artisan config:cache after you make changes in your .env file.
Response code 530 indicates that you have not allowed Less Secure Apps to use your Gmail account.
You will need to enable this in your Google settings. Here's a link.
After you have allowed this, the email should go through.
If you're just testing, I would recommend using an SMTP testing server, such as Mailtrap. It's free and will avoid the security risk that comes with allowing less secure apps to use your Gmail account.
Please turn on Less secure app access for your SMTP email account.
From the following url go to: Google Account
Am trying to send email by Laravel.
But It's getting error.
.env file Configuration below :
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myemailID#gmail.com
MAIL_PASSWORD=******
MAIL_ENCRYPTION=tls
Controller Code Below :
$data = array('name'=>"Ripon Uddin", "body" => "Test mail");
Mail::send('email', $data, function($message) {
$message->to('ToEmailID#yahoo.com','To My Yahoo')->subject('Laravel Test Email');
$message->from('ToFromID#gmail.com','Ripon Uddin (Laravel Lover)');
});
Error gettings :
Failed to authenticate on SMTP server with username "myEmailID#gmail.com" using 3 possible authenticators. Authenticator LOGIN returned Swift_TransportException: Expected response code 235 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 r18-v6sm7406256pgv.17 - gsmtp " in
you don't need to have GSuite to do this... I have done this integration alot of times with Laravel & GMail. Just go to your Google Account > Security > Less secure app access and Click on "Turn on access (not recommneded)"See image for more info
Go to this link or app password page of gmail then select 'mail' as "app" and custome name as "device". Then you will get app password.
Just go to your laravel mai.php under config folder in production or env file in dev mode. Paste the generated code on password section 'password' => 'generated code',
After all run: php artisan config:cache
Google changed its security policy. Now "Allow less secure apps" option is not available under Sign-in & security.
The idea is that Gmail does not allow any application to access a user's Gmail account, even with its real username and password. That's why people are getting the error. The new mechanism is you should create an application in your Google account and Google will generate a password for that application. Gmail will allow access with that Password and real username/Gmail ID.
The solution is
Step 1: sign-in to your Gmail account and to "Manage Your Account" as seen in the image below
Step 2: Click on the Security Tab in the left sidebar,
Step 3: Enable 2-step verification first for SMTP access.
You will not see "App Password" option until you enable 2-step verification.
After enabling 2-step verification click on "App Password". You will see like this
Click on the first dropdown and select "Other (Custom Name)". In the new window write your application name and git the Generate button. Copy the password that showed up.
Use this password, instead of your real Gmail password. SMTP configuration should look like
This config works on Gmail if you "Allow less secure apps" setting enabled in your gmail settings:
mailer_transport: smtp
mailer_host: smtp.gmail.com
mailer_port: 465
mailer_encryption: ssl
mailer_auth_mode: login
mailer_user: xxxx#xxxxxxx.com
mailer_password: "xxxx"
This one works on Gmail Suite if you white list the ip of your server in your gmail settings (see https://support.google.com/a/answer/2956491):
mailer_transport: smtp
mailer_host: smtp-relay.gmail.com
mailer_port: 587
mailer_encryption: tls
mailer_auth_mode: login
mailer_user: xxx#xxxxxxx.com
mailer_password: "xxxx"
Make sure your user credentials are right in .env file.
Try putting your passwords in quotes. eg: MAIL_PASSWORD="mypassword"
To apply your changes Run
php artisan config:cache
Did you turn on the "Allow less secure apps" on? go to this link
https://myaccount.google.com/security#connectedapps
Take a look at the Sign-in & security -> Apps with account access menu.
You must turn the option "Allow less secure apps" ON.
I am using laravel 5.4.
While sending verification email, i got the aforementioned error.
I don't know what i am doing wrong this is my env file:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=shahzadshah5741#gmail.com
MAIL_PASSWORD=hussain57421
MAIL_ENCRYPTION=tls
Two ways:
Go to your Google Account Management page
Under the Security options, click Edit link of Authorising applications & sites
Under gmail settings, you need to access https://www.google.com/settings/security/lesssecureapps
and set 'Access for less secure apps' to "Enabled"
I can send my emails in localhost flawlessly. but ever since I uploaded my program into a hosting site I get this error
Expected response code 250 but got code "", with message ""
I also updated the .env file.
MAIL_DRIVER=smtp
MAIL_HOST=smtp-mail.outlook.com
MAIL_PORT=587
MAIL_USERNAME=email#outlook.com
MAIL_PASSWORD=123456789
works in localhost but not in the hosting site.
i am using laravel 5
I ran through this error so many times for some reasons.
When see this error,
Expected response code 250 but got code “”, with message “”
Please triple check your email password.
Note :
Test your credentals first on a phone app or log-in into the mail site.
If pass, you may update in your .env file
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mail.yahoo.com
MAIL_PORT=465
MAIL_USERNAME=dev.bheng#yahoo.com
MAIL_PASSWORD=****
If you know for sure that your password is correct.
Check to make sure your Gmail or Yahoo Mail allow app log-in.
Example
Yahoo
we solved this problem by clearing the Laravel's configuration cache
php artisan config:clear
looks like the smtp was blocked for hostinger free users.
http://www.hostinger.ph/forum/news-and-announcements/229-email-service-updates-1.html
This one worked for me, 'if you are using GMAIL'
Go to 'My Accounts'
Go to 'Sign-in & security'
Scroll down to 'Allow less secure apps'
Switch #3 to ON
After doing this and if you just recently set up your email configurations on laravel and still doesn't work, try running:
php artisan config:cache
I've a working laravel swiftmailer using google server. Here my steps:
I visited the link
https://www.google.com/settings/security/lesssecureapps and turned
on less secure apps.
I edited .env file as like below:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=username //i.e. username#gmail.com
MAIL_PASSWORD=password //Gmail accounts password
MAIL_ENCRYPTION=ssl
Edit username and password with your own.
In my controller, I wrote the following code:
$rawData = request::all();
Mail::queue('program.meeting.emailInvite', $rawData, function($message) use ($rawData)
{
$message->from('info#echosofts.com', 'Echosofts')->to(array_map('trim', explode(',', $rawData['all_email_id'])))->subject($rawData['mail_title']);
});
Then email was working fine except the sender email ID was my google account (username#gmail.com) instead of info#echosofts.com.
To overcome the sender email changing problem, I visited my google account and did the following:
"Setting icon"-> Settings -> Accounts and Import->Send mail as->Add another email address your own.
The following settings depends on your configuration.
Email address: info#echosofts.com
SMTP server: mail.echosofts.com
Username: info#echosofts.com
password:**********
Port:25
FWIW - I get this error when sending a email with an empty string in the to field.
in "mautic" (CRM), if you mail to a large amount of contacts, like more than 10k this occurs. The real reason is mostly a wrong configuration in php settings. For example:
max_input_time = 60
Will only let your server run the script for 60 seconds, try a higher value.
PHP configuration depends on your server and its installed software, mostly configured by htaccess or php.ini file.