Laravel - Password Reset - Can´t Send Messages - php

I used the artisan command "php artisan make:auth" And Users authentication and registration is working fine but for some reason the App just can't send the reset passwords email.
I was able to properly configure the env file and even receive the message; "We have e-mailed your password reset link!", but the email never reaches the recipient.
This is my env file:
MAIL_DRIVER=log
MAIL_HOST=smtp.liberumratings.com
MAIL_PORT=587
MAIL_USERNAME=website#liberumratings.com
MAIL_PASSWORD=******
MAIL_ENCRYPTION=tls
I also tried the example below but a got this error:
(1/1) ErrorException
stream_socket_enable_crypto(): Peer certificate CN=*.locaweb.com.br'
did not match expected CN=smtp.liberumratings.com'
MAIL_DRIVER=smtp
MAIL_HOST=smtp.liberumratings.com
MAIL_PORT=587
MAIL_USERNAME=website#liberumratings.com
MAIL_PASSWORD=******
MAIL_ENCRYPTION=tls
All my parameters are correct and I am able to send emails using the PHPMailer on the same server on another application.

The encryption might be wrong. Are you using SSL?
Remove the tls and try agian. Also your answer can be found here
Laravel SMTP driver with TLS encryption

Related

MailGun returning error 421 on Laravel Application

I have a free tier account on MailGun and I'm trying to configure the application to send the user a token to reset his password but I keep getting the following error in my browser console.
"Expected response code "220" but got code "421", with message "421 Server busy, too many connections".
This is how my .env file is configured
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=postmaster#sandbox6xxxxxxxxxxxxxxx.mailgun.org
MAIL_PASSWORD=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
MAIL_ENCRYPTION=tls
Why are you using the smtp config? Laravel comes with a Mailgun driver built in. You should be setting your MAILER to mailgun and then configuring your mailgun domain, key, and email address.
See here: https://laravel.com/docs/9.x/mail#mailgun-driver

Error when I send email using Office365 in Laravel

In Laravel 7, I want to send email from my application using Office365, tried email password and app password none worked.
MAIL_MAILER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
MAIL_USERNAME=my-email-here
MAIL_PASSWORD=my-email-password-here
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=my-email-here
MAIL_FROM_NAME="App name"
In the above code MAIL_PASSWORD is my email password not app password
this configuration gives me the following error
Failed to authenticate on SMTP server with username "support#tingsapp.com" using 2 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "451", with message "451 4.7.0 Temporary server error. Please try again later. PRX4 [MRXP264CA0044.FRAP264.PROD.OUTLOOK.COM]
". Authenticator XOAUTH2 returned Expected response code 235 but got code "535", with message "535 5.7.3 Authentication unsuccessful [MRXP264CA0044.FRAP264.PROD.OUTLOOK.COM]
In the second try I put App Password created in office.com as MAIL_PASSWORD value, but I get same error.
after changing the .env I run php artisan cache:clear and php artisan config:cache
Is there anything I missed, please
you need to put the password in double-quotes.
Replace: MAIL_PASSWORD=yourpassword
With: MAIL_PASSWORD="yourpassword"
after changing the .env just run:
php artisan cache:clear
You have to use your email instead of password on MAIL_FROM_ADDRESS like this
MAIL_MAILER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
MAIL_USERNAME=my-email-here
MAIL_PASSWORD=my-email-password-here
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=my-email-here
MAIL_FROM_NAME="App name"
or you can use smtp-mail.outlook.com as MAIL_HOST
MAIL_MAILER=smtp
MAIL_HOST=smtp-mail.outlook.com
MAIL_PORT=587
MAIL_USERNAME=my-email-here
MAIL_PASSWORD=my-email-password-here
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=my-email-here
MAIL_FROM_NAME="App name"

Error code 450 Requested mail action not taken: mailbox unavailable when send email laravel

I want to send email to user. I have created using gmail smtp setting and it's working normally but when I tried send email using yahoo smtp setting it's not working and show error code like below
Swift_TransportException (450)
Expected response code 250 but got code "450", with message "450 Requested mail action not taken: mailbox unavailable "
I've cache config laravel using php artisan config:cache but it's still not working as normal as gmail settings
Here's .env file
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mail.yahoo.com
MAIL_PORT=587
MAIL_USERNAME=xxxx#yahoo.com
MAIL_PASSWORD=xxxx
MAIL_ENCRYPTION=tls
Do you know if there's any settings that I forgot ?
Thank you
try restart your server and try again and also show your credentials in your env file.
Probably you need to enable below option from your yahoo account:
Account Security -> Allow apps that use less secure sign in

Sending email in heroku host since laravel 5.4

I am trying to send an email confirmation account from a web application made in laravel 5.4, I have tested in my localhost and it is sent correctly, but when deployed in heroku throws me this error:
Swift_TransportException in AbstractSmtpTransport.php line 383:
Expected response code 250 but got code "530", with message "530-5.5.1
Authentication Required.
Learn more at
530 5.5.1 https://support.google.com/mail/answer/14257 w10sm15831823wjk.18 -
gsmtp"
I have already configured the application key from gmail, even the tests from the localhost are positive, but since heroku fails to send the email.
These are my settings in the .env file:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=micorreo#gmail.com
MAIL_PASSWORD=mvallokmzmszjtwk
MAIL_ENCRYPTION=tls
You have to configure add-on mail in heroku https://devcenter.heroku.com/articles/smtp

Laravel 5: Sending Email

I am trying to send an email in laravel application.
Here is my .env file:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=ehsan.sani91#gmail.com
MAIL_PASSWORD=**********
MAIL_ENCRYPTION=tls
And here is the Mail::send method:
Mail::send('email', ['name' => "EE"], function($m){
$m->to('ee#dx.com', 'Malik')->subject('Subjet of the email');
});
And here is the error:
Swift_TransportException in AbstractSmtpTransport.php line 383: Expected response code 250 but got code "530", with message "530 5.7.0 Must issue a STARTTLS command first. s16sm7748968wib.16 - gsmtp"
Any help?
Well, I got it. Infact the email was not authenticated because that email required a mobile phone authentication after login. changing to other email address that required just login credentials, it worked.
.env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=youremail#host.com
MAIL_PASSWORD=yourpassword
MAIL_ENCRYPTION=tls
GMail SMTP requires encryption. Try changing setting as following.
MAIL_PORT=465
MAIL_ENCRYPTION=ssl
I made the following mistake:
I did not actually include the
'encryption' => env('MAIL_ENCRYPTION'),
to the array return in mail.php. I did include my host, port, username and password in the mail.php but not the encryption method (the encryption method I only included in the .env file), so trying out these mentioned solutions did bring a change in the error messages outcome, created a bigger confusion, but none solved the problem. Hope this helps someone!

Categories