having issues on sending email in laravel 5.8 - laravel

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

Related

email verification on laravel 7

I have a question, actually, I'm developing a web site using laravel 7 and I successfully make an email verification and password reset functionality using mailtrap.io; but all theses just in localhost, I'm wondering if there is any other way to use it in the production side because I want users to receive the email verification and password reset response on them's email not on mailtrap website.
here is an image shows the email verification and password reset response
enter image description here
You can use sendgrid.com for mail delivery.
Make sure you configure DNS correctly before using it and configure the White Label correctly for you Domain.
.env
MAIL_MAILER=smtp
MAIL_HOST=smtp.sendgrid.com
MAIL_PORT=465
MAIL_USERNAME=apikey
MAIL_PASSWORD=your_api_key_here
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=no-reply#yourdomain.com
MAIL_FROM_NAME="${APP_NAME}"

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.

Laravel mail on shared hosting

I've a form contact on my website and I want the form to be sent via email when submitted.
I've tried it in xampp and it's working fine.
On shared hosting, it does not work.
I'm using my own custom domain smtp.
Someone can explain me why it's not working ?
Your shared hosting probably blocks outgoing SMTP connections. Many hosting providers do that to prevent spam. You can try using a HTTP/WEB API instead of SMTP to send email.
Some email APIs like Flute Mail allow you to set up an HTTP API connection which can immediately forward the request through your "custom domain smtp" server. So you can keep using your custom domain email server, but get an API for it.
Otherwise you'll have to set up a Web API yourself with an open source tool like Postal.
In your laravel .env file if add following parameters mentioned below and create a e-mail on your shared hosting and add username, password and host of your hosting.
MAIL_DRIVER=smtp
MAIL_HOST=shared_host_name
MAIL_PORT=587
MAIL_USERNAME=mail#sharedhost.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
I suppose then it would work fine.

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
`

Laravel's Mail notification won't send, but Laravel's Mail::Raw will

I have configured my SMTP server correctly in Laravel's env file, and can successfully send an email using Mail::raw e.g.
Mail::raw("This is a test message", function ($message)
{
$message->from(env("MAIL_ORDER_ADDRESS"), 'Orders');
$message->to('user#example.com');
$message->subject('Test Message');
});
However, when I use a laravel 5.3 mail notification, no email is received (nor is an error generated). I have tested the same notification code locally using mail trap and the notifications work correctly.
I can't understand how if the mail server is working and can be used with Mail::raw, it doesn't automatically work with notifications when I have tested locally and confirm they are coded correctly.
Note: Using shared hosting on NameCheap.
Any ideas?
FIXED: It was because I had not configured "From" in config/mail.php and because the domains didn't match, it wasn't set.
The opposite situation is occurring for me. I have the MAIL_DRIVER=mail set within the .env file.
I have set MAIL_FROM_ADDRESS & MAIL_FROM_NAME within the .env file and viewed the app/config/mail.php
Mail::raw is sending out email correctly via the Postfix logs but any emails sent via the new Laravel 5.3 Notifications is not working. No errors or any information writing to the logs.
There appears to be some other issue occurring.
I had the same issue. During testing for Mail::raw, i had set MAIL_ENCRYPTION to empty.
When I set MAIL_ENCRYPTION=tls for notify email, it started working.

Resources