These are the settings in my env file
MAIL_MAILER=smtp
MAIL_HOST=mail.codestudio.pk
MAIL_PORT=465
MAIL_USERNAME=hamza.niazi#codestudio.pk
MAIL_PASSWORD=**********
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=
MAIL_FROM_NAME="${APP_NAME}"
When I test on mailtrap.io it works fine also works fine with my gmail account. But whenever I try to send mail through my domain it gives this error.
Connection could not be established with host mail.codestudio.pk :stream_socket_client(): unable to connect to tcp://mail.codestudio.pk:465 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
I hope this env works for you. I used the same setting to run it on my server
#MAIL_MAILER=smtp
#MAIL_ENCRYPTION=tls
#MAIL_PORT=465
MAIL_HOST=codestudio.pk
MAIL_USERNAME=hamza.niazi#codestudio.pk
MAIL_PASSWORD=**********
MAIL_FROM_ADDRESS=hamza.niazi#codestudio.pk
MAIL_FROM_NAME="${APP_NAME}"
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'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
I'm working on a laravel project (maintenance of an existing project).
The reset password was not working.. I fixed the issue by changing the .env file on my localhost.
It was
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
I changed it to
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=email#mailtrap.io
MAIL_PASSWORD=the password
MAIL_ENCRYPTION=null
It works fine on my localhost.. When I change the .env.example on bitbucket it still doesn't work and gives me the same error
Swift_TransportException in AuthHandler.php line 181:
Failed to authenticate on SMTP server with username "noreply#igpastpapers.com" using 2 possible authenticators
Any ideas?
Make sure you change your .env file in your production code, NOT your .env.example file. The .env.example is only setup so you can see the build of your .env file wherever you keep your version control code (Git, etc), without actually having the secure data shown. Check this link out:
Environment Configuration
I am using inbuilt template of Login System in Laravel 5.1
When I use Forgot Password on localhost, everything works. Below are my keys in .env file
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=userid
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
When I try the same thing on Godaddy server, I am facing the below error.
Swift_TransportException in StreamBuffer.php line 265: Connection
could not be established with host smtp.gmail.com [Connection refused
111]
Your env file must be like below
MAIL_DRIVER=smtp
MAIL_HOST=localhost
MAIL_PORT=465
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=ssl
In your config/mail.php, the from value should be like below...
'from' => ['address' => 'pankaj#YourDomainName.com', 'name' => 'Sender Name'],
What's your domain Name in from ? or you can say, How to create Email account in GoDaddy ?
Login in your GoDaddy Account
Go to your Hosting Account.
Click Manage
Under Email category, Please click Accounts
Create an account if there is no email account.
and that's it.
So let's say you have email address like Pankaj#yourdomainname.com
Now, put this email address in config/mail.php for from field. That's it.
This will 100% fix the issue
I had a hell of a time trying to find an answer to this so hopefully this helps someone. I was able to relay using my GoDaddy email account settings for a while but for whatever reason that stopped working. I'm now using the standard PHP Mail function to send emails and here's the .env config for that. Not sure if port or encryption are necessary but it's working so left it as is.
MAIL_DRIVER=mail
MAIL_HOST=localhost
MAIL_PORT=465
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=ssl
Looking around web, it seems when using GoDaddy you need to use their relay SMTP with Gmail credentials when you want to send an e-mail.
So in your .env file instead of:
MAIL_HOST=smtp.gmail.com
you should use
MAIL_HOST=here_godaddy_relay_server
The exact value of relay server depends on hosting you have but it will be probably relay-hosting.secureserver.net so try first with:
MAIL_HOST=relay-hosting.secureserver.net
Further details: https://www.godaddy.com/help/what-is-the-name-of-my-hosting-accounts-relay-server-953+&cd=2&hl=en&ct=clnk&gl=us
For my shared hosting at goDaddy
I could configure my .env with the values from cPanel->Email Wizard->Configure Mail Client
For Config email to your Laravel project first, create an email account in the host and check config details.
Now config you .env file example:
MAIL_DRIVER=mail
MAIL_HOST=mail.22h.in
MAIL_PORT=587
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls
And your config/mail.php Should be like this.
'from' => ['address' => 'demo#domain.in', 'name' => 'Order Receipt'],
Clear your project cache and config , Run these command
php artisan config:Cache
php artisan cache:Clear
One of the reasons could be wrong Mail_RRIVER etc in the .env file. Please make sure you put the right information there, e. g. for GMAIL the following input will work!
MAIL_DRIVER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_USERNAME=**<YOUR_USER_NAME>**#gmail.com
MAIL_PASSWORD=**<YOUR_PASSWORD>**
MAIL_ENCRYPTION=ssl
Update for Laravel 7 and up
MAIL_MAILER=smtp
MAIL_HOST=localhost
MAIL_PORT=25
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=null