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

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.

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.

Laravel 6 send mail

I have an issue with authentication while sending mail with Laravel smtp driver.
.env file:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=account#gmail.com
MAIL_FROM_ADDRESS=account#gmail.com
MAIL_PASSWORD=app_password
MAIL_ENCRYPTION=tls
It gives the following error:
"530-5.7.0 Authentication Required. "
2-Factor auth is enabled and app password is used;
Also tried with SSL on 465, same error;
Config is flushed every time .env is changed;
Everything in config/mail corresponds to .env;
SO all typical solutions are not working. What else may cause this problem?
I have also tried using smtp.vivaldi.net with vivaldi account, it authenticates, but gives an error:
"no valid recipients"
while recipient email is surely valid, which is also strange for me.
I've stumbled across this multiple times already, hence I do not remember the exact error-message which I received but here is my assumption.
Google has an option called "less secure apps" which you need to enable in order to send directly mails through their SMTP interface. Can you check if this flag is disabled and try to enable it?
https://support.google.com/a/answer/6260879
In addition to that google is slowly deprecating this feature. Starting from Mid 2020 you'll be not able to enable this flag anymore and they will completely remove this in 2021.
Reference: https://gsuiteupdates.googleblog.com/2019/12/less-secure-apps-oauth-google-username-password-incorrect.html
Firstly, you need to setup 2 step verification here google security.
An App Password link will appear and you can get your App Password to insert into below "MAIL_PASSWORD". More info on getting App Password here
MAIL_DRIVER=smtp
MAIL_FROM_ADDRESS=noreply#talhaf.com
MAIL_FROM_NAME=System
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=YOUR_GMAIL#gmail.com
MAIL_PASSWORD=YOUR_GMAIL_CREATED_APP_PASSWORD
MAIL_ENCRYPTION=tls
Don't forget to clear cache with :
php artisan config:cache
Problem was that I messed up with config/mail.php.
I wrote
'username' => env('email'),
'password' => env('app_password'),
Instead of
'username' => env('MAIL_USERNAME','email'),
'password' => env('MAIL_PASSWORD','app_password'),

having issues on sending email in laravel 5.8

I am having issues on sending email via notification. I tried accessing the mailbox using the credentials I put in .env, the credential is good I am able to access the inbox but if I run the command sending email is failed.
on my .env
MAIL_DRIVER=smtp
MAIL_HOST=myhost
MAIL_PORT=465
MAIL_USERNAME=this#isworkingemail.com
MAIL_PASSWORD=pWdisWorking
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=this#isworkingemail.com
MAIL_FROM_NAME='AFTSCredit'
my function via
public function via($notifiable)
{
return [TwilioChannel::class,'database','mail'];
// return [TwilioChannel::class,'database'];
}
any idea? plase help thank you in advance!
Your error says Authentication error. This is nothing to do with Laravel/PHP mailer.
Try one of these below:
Clear cache
Check if you have modified config file. Make sure your .env variables are being pointed in your config file
Check if your server allows outbound emails
Check if you have right credentials such as host name, username, password
If you need extra authentication to allow using smtp services like google. You will need to activate to allow to use less secure app.
Finally, but not the least
If your mail server password contains a # then you should quote the environment string since everything after # will be taken as comment (starting in Laravel 5.8)
put the port and host as follows
MAIL_PORT = 587
MAIL_HOST= smtp.gmail.com
and also in your gmail . Disable two authentication and enabled unsecured apps
and then it would be okkay

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

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....

C-panel not sending Laravel mail

So I currently have setup my laravel project in C-panel, and have updated the .env file to have the appropriate email address. When I, for instance, use the make:auth reset password feature it responds with the appropriate "We have e-mailed your password reset link!", but there is no mail sent.
I am not sure how to test this to find the hole in the problem. When I used mailtrap I was able to send and receive emails no problem, but there is some issue with the webmail in c-panel not processing and sending out an email from Laravel 5.4
Help please
change your .env file. set MAIL_DRIVER=mail it will start working. make sure you set from in mail.php
`

Resources