email verification on laravel 7 - laravel

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}"

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 send message from Laravel controller

I tried to send an email from a Laravel controller, but it's showing this error. I'm not using a two step verified Gmail account. Most tutorials use the "enable less secure app" settings, but I can't enable that option in my account.
this is my env file
MAIL_MAILER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_USERNAME=******
MAIL_PASSWORD=******
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=********
MAIL_FROM_NAME="${APP_NAME}"
Please use your google app password in MAIL_PASSWORD

laravel "error when sending email fwrite(): send of 18 bytes failed with errno=10054"

I am using laravel I got this error when I send emails
fwrite(): send of 18 bytes failed with errno=10054 An existing connection was forcibly closed by the remote host.
it was working normally
this is my configuration
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=givkom#gmail.com
MAIL_PASSWORD=123456789
MAIL_ENCRYPTION=tls
Mail::to($request->email)->send(new DonorMail());
change .env file like this:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_USERNAME=ENTER_YOUR_EMAIL_ADDRESS(GMAIL)
MAIL_PASSWORD=ENTER_YOUR_GMAIL_PASSWORD
MAIL_ENCRYPTION=ssl
The MAIL_USERNAME and PASSWORD should be replaced with your Gmail Email address and Password respectively.
Since we are using Gmail SMTP, we need to change some security settings on our Google account, to give access to less secured applications.
Configure your Google Account
Login to your Google Email Account and click on Google Account Button.
Once you are on My Account Page then click on Security and scroll down to the bottom and you will find ‘Less secure app access’ settings. Click on the radio button to set it ON.

Error Expected response code 250 but got code "550", with message "550 This is a submission only port. You must authenticate before sending mail

I have the centos server with laravel setup. I am facing issue while sending email from server. My laravel version is 5.8.29 and PHP version is 7.3.6. I am using SMTP to send email. Guys please do help me out. Here are my code.
It's very strange to say that from my local setup from my system I am able to send email with same SMTP details with current project setup with same code. But some how on production server the emails are not sending. I have cross checked with swift mailer and tested with separate file for only email send and its work. But from actual environment is not work.
.env file
MAIL_DRIVER=smtp
MAIL_HOST=mail.domain.com
MAIL_PORT=587
mail_username=username
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
Email should be send from the environment file
If you want to send an e-mail via Gmail then you need to verify your Gmail account with 2 step verification and generate mail password. for verifying your Gmail account to throw this link enter link description here after verifying your account go to "security->app password" generate mail password. select app "mail" and select device "window computer" copy the generated password paste into your .env file
Your .env file show look like:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=username
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
After saving your.env file, remove project config and cache with the command
php artisan config:cache
php artisan cache:clear
For sending an email via Domain follow this link enter link description here

Laravel send email verification to a registered user

I am new to Laravel. I have easily implemented Laravel email verification for the registered based on Laravel https://laravel.com/docs/5.8/verification
its working fine for testing purpose in local server. now I want to upload to server. now it's using default Mailtrap to receive an email of all the users.
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=****
MAIL_PASSWORD=****
MAIL_ENCRYPTION=tls
//user.php
class User extends Authenticatable implements MustVerifyEmail
{
use Notifiable;
My requirement is after registering, the email should send to the registered emailId, not to the mailtrap account. I have researched a lot on this in google but all the solution is only for sending emails to mailtrap or others but instead, I want to send to the users' email ID with the verification link.
I am assuming you have successfully implemented the activation email.
For your application to send email to the registered user email address you need to provide your email server SMTP credentials. For live application, you can not use mail trap credentials. If you use mailtrap credentials you will only get emails to your mail trap account.
If you do not have live smtp server credential, you can create a Gmail account and user Gmail SMTP credentials.
And one more thing, if you are using Gmail, change settings for Less secure app from your google account.
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=****
MAIL_PASSWORD=****
MAIL_ENCRYPTION=tls
this is .env configuration you have change to your own mail server. so that laravel will send email using these settings to the registered users.

Resources