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
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 am using go daddy cpanel email to send an email using laravel. This is the code i am using:
MAIL_DRIVER=SMTP
MAIL_HOST=sg3plcpnl0013.prod.sin3.secureserver.net
MAIL_PORT=465
MAIL_USERNAME=myusername
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=tls
MAIL_FROM_NAME="Contact Us"
MAIL_FROM_ADDRESS=memail#mail.com
Error:
Swift_TransportException
Connection to tcp://sg3plcpnl0013.prod.sin3.secureserver.net:465 Timed Out
If your Laravel hosted on the godaddy you may just use directyle the sendmail function for your Email service notifications.
please change APP_URL=http://localhost to
URL=http://your-ip-address
it's in the .env
sorry my english is not good
I got the issue below:
Swift_TransportException
Connection could not be established with host smtp.gmail.com [ #0]
when sending mail in Laravel on localhost but work perfectly on online server.
Tried many tricks and solutions but no success. Can anyone help on this issue?
My .env file looks like this:
.env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=XXXXXX#gmail.com
MAIL_PASSWORD="**********"
MAIL_ENCRYPTION=ssl
don't use your gmail password instead of that you can generate app password in gmail use that also don't go for less secure
here how's your env look like
MAIL_ENCRYPTION=tls
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=examle#gmail.com
MAIL_PASSWORD=somestringbygmail
generate your app password by visting here
I have a problem with my laravel email client.
I need to send email by click button.
my code:
.env
MAIL_DRIVER=smtp
MAIL_HOST=mail.somedomain.com
MAIL_PORT=587
MAIL_USERNAME=test#somedomain.com
MAIL_PASSWORD=123456
MAIL_ENCRYPTION=null
I think it is good configuration, of course i'm using my domain :)
next in controller I have code like this:
Mail::send('home', array('firstname' => "fname"), function($message){
$message->to("testsend#somedomain.com")->subject('Welcome to the Laravel');
});
Website is open normally but email not send
In Gmail account
My account > Sign In And Security > Sign In to google, enable two step verification
http://i.prntscr.com/7c849cb520e84f02b39216f3662590bc.png
http://i.prntscr.com/cc52e9b8e7c2472496f1e2d2ec8185f8.png
Create One App and generate password
http://i.prntscr.com/b38cdca0724446d8a53b22dfa5f43ee6.png
In your .env file
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myemail#gmail.com
MAIL_PASSWORD=apppassword // this is created from gmail app password
MAIL_ENCRYPTION=tls
And Then run php artisan config:cache