I'm trying to use Laravel's auth package, and I'm getting various errors when trying to use its "send password reset link" option. I'm using MAMP as the server. My .env by default looks like this:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
I keep getting Swift_TransportException errors when I try to send mail.
Am I supposed to connect a Gmail address I own, using my email and password, essentially telling Laravel to use Gmail as the mail server? Isn't this a security risk since my password would be out in the open?
As an alternative, can/should I add a mail server to MAMP and use its credentials? Again, isn't that a security risk?
This configuration will save emails to log file:
MAIL_DRIVER=log
MAIL_HOST=mailtrap.io
MAIL_PORT=587
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=tls
If you register in Sendgrid, you will be able to use their smtp server.
This configuration will use Sendgrid as smtp Server:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=your_user_name_from_sendgrid
MAIL_PASSWORD=your_password_from_password
MAIL_ENCRYPTION=tls
Related
I am trying to send an email to a guest in laravel.
Below is my code:
Mail::to($requestor->email)->send(new ApprovedNotification(auth()->user()->name));
The question is how can I send the email through proxy? Does it requires any server side configuration or I can just set it in laravel? The code is running fine when I am using my home network but when using my company server, the SMTP can't be sent out. ( The weird thing is the Jetstream team invitation email can be sent, but the customized emails cant)
Below is my email configuration:
MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=xxxxxx#gmail.com
MAIL_PASSWORD=xxxxxxx
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=xxxxxx#gmail.com
MAIL_FROM_NAME="${APP_NAME}"
Thanks in advance!
If you are using Gmail then you must generate App password.
https://support.google.com/accounts/answer/185833/sign-in-with-app-passwords?hl=en
then your mail configuration look like this
MAIL_MAILER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=587
MAIL_USERNAME=xxxxxxxxxx#gmail.com
MAIL_PASSWORD=xxxxxxxxxx
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=xxxxxxxxx#gmail.com
MAIL_FROM_NAME="${APP_NAME}"
So i have created an App in Laravel 7 and Deployed it in Godaddy Shared hosting, everything works except for the Mailing.
This is the .env values
MAIL_MAILER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
MAIL_USERNAME=email#outlook.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=TLS
MAIL_FROM_ADDRESS=email#outlook.com
MAIL_FROM_NAME="YourName"
and the value in config/mail.php
'default' => env('MAIL_MAILER', 'smtp')
This is working Perfectly in Localhost, but when i deployed to goDaddy shared hosting, this doesnt seems to work.
I have tried changing the value to .env value to MAIL_MAILER=sendmail and congif/mail.php to 'default' => env('MAIL_MAILER', 'sendmail')
This doesnt show any error, also displayed to Success Message. but Mail not being sent.
What is the Fix ?
Change your .env
MAIL_MAILER=smtp
MAIL_HOST=localhost
MAIL_PORT=25
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=no-reply#your_godaddy_domain.com
MAIL_FROM_NAME="${APP_NAME}"
It seems that GoDaddy blocks SMTP ports to avoid the usage of third-party SMTP services [1] [2]. In order to send emails, GoDaddy says to use their SMTP relay server, which requires no authentication. So your env would look like:
MAIL_MAILER=smtp
MAIL_HOST=relay-hosting.secureserver.net
MAIL_PORT=25
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=email#yourgodaddydomain.com
MAIL_FROM_NAME="YourName"
Emails from shared hosts are highly likely to be blacklisted by most servers.
Your next option would be to use an email API such as Mailgun or Sendgrid (there are other providers too of cause). Both of them have a free plan which has a limited quota so you can try.
Finally, your last resort would be to ditch GoDaddy (I never liked them anyway) and move to another host provider. I suggest DigitalOcean (ask me for referral link to get $25 😄) or AWS.
I have a laravel app that needs to connect to an external SMTP server and log in to send a email. How could i configure my local postfix to be said server and have the app log into it? I already have postfix completely set up with proper dns and domain names (MX, etc) and it works flawlessly for sending emails through the command line.
You can configure Laravel to use your local SMTP server.
You can try that in your .env configuration:
MAIL_DRIVER=smtp
MAIL_HOST=localhost
MAIL_PORT=25
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
I tried loading my page I created using laravel and after I hit the registration button and I got the above error message, please what must I do?
Mailtrap is an email testing service for testing. It will catch all the mail sent from your application, so you can test mails without sending it to client. In order to use it, you have to follow these steps:
First you have to create an account on Mailtrap. Then go to your dashboard and note your credentials. It may be something like:
Username: 05921688469af01
Password: 2efe39296ae5b7f
Then paste this values in your .env file of your Laravel application (the username must be pasted in MAIL_USERNAME and the password must be pasted in MAIL_PASSWORD).
It might look like this:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=05921688469af01
MAIL_PASSWORD=2efe39296ae5b7f
MAIL_ENCRYPTION=null
Then try again and it will work! You can go to your Mailtrap dashboard to see the result.
Check below settings if you are using in your .env file of root folder of project.
MAIL_DRIVER=smtp
MAIL_HOST=smtp.yourdomainname.com
MAIL_PORT=2525
MAIL_USERNAME=email#yourdomainname.com
MAIL_PASSWORD= ********
MAIL_ENCRYPTION=null
Or
if you are using Gmail for sending a email then do following settings.
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=******#gmail.com
MAIL_PASSWORD=*****
MAIL_ENCRYPTION=ssl
Try to use another SMTP port (2525, 465 or 25) https://mailtrap.io/faq#faq14
And also make sure to set your credentials which you got from mailtrap in .envfile
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=your mailtrap username
MAIL_PASSWORD=your mailtrap password
MAIL_ENCRYPTION=null
I'm new to php/laravel tech.
My .env file contains following configuration[1];
When I try to reset the password, It says, password link has been sent, But I haven't received any emails.
What I'm doing wrong here?
p.s: I'm providing null for MAIL_ENCRYPTION/ MAIL_USERNAME, due to one issue I faced.(Swift_TransportException Failed to authenticate on SMTP server with username "abc#abc.com" using 2 possible authenticators)
[1]
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=2525
MAIL_ENCRYPTION=null
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_FROM_ADDRESS=abc#abc.com
MAIL_FROM_NAME="Administrator"