2

I'm working in mail in laravel. I've following configuration.

MAIL_DRIVER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=********
MAIL_PASSWORD=########
MAIL_ENCRYPTION=tls

I've already tried this one but not working

stream_socket_enable_crypto(): Peer certificate CN=`cs723.mojohost.com' did not match expected CN=`smtp.sendgrid.net'

And many more similar question but still i don't get the solution. I've following error:

ErrorException (E_WARNING) stream_socket_enable_crypto(): Peer certificate CN=gains.nanosupercloud.com' did not match expected CN=smtp.sendgrid.net'

I don't know what i'm doing wrong. Here is the code used for email sending.

public function toMail($notifiable)
{
    return (new MailMessage)
                ->from(\Config::get('values.app_email'),\Config::get('values.app_name'))
                ->subject('Successfully approved your Company')
                ->greeting(sprintf('Hello %s', $this->user->name))
                ->line('Your company has been approved successfully. Now, it will be visible to our website');
}

Any kind of suggestions are appreciated.

Note: Everything works perfectly in local server(ubantu 16.04)

6
  • Same error for me while it is working perfectly in the local environment. @SagarGautam did you find any solution for this?
    – Ishaan
    Commented Aug 3, 2019 at 12:43
  • @Ishaan It was issue of using sendgrid in server. Use the server email account for sending emails it will work perfectly Commented Aug 3, 2019 at 12:45
  • So you mean, to change the MAIL_FROM_ADDRESS from .env file ?
    – Ishaan
    Commented Aug 3, 2019 at 12:52
  • @Ishaan yes and other variables too in mail configuration Commented Aug 3, 2019 at 12:59
  • So ultimately we are not sending emails from sendgrid anymore?
    – Ishaan
    Commented Aug 3, 2019 at 13:01

5 Answers 5

12

The answer i am giving may look funny but i have same error while sending mail in the live server

just change this

MAIL_DRIVER=smtp

to

MAIL_DRIVER=sendmail

I don't know the reason How the hell is this working but it works fine for me

2
  • I've tried this before but still gives some problem. Error is : proc_open() has been disabled for security reasons Commented Dec 31, 2018 at 6:50
  • I think i may be blocked port of the website Please Contact Your Hosting Provider or Rise the support ticket to them` Can You Please Share the screen Shot of the error You are getting So that i may Help You
    – ManojKiran
    Commented Dec 31, 2018 at 7:00
2

add this line in .env file to disable mail encryption

MAIL_ENCRYPTION = NULL
0
2

I had similar issue, what I did was change the

MAIL_DRIVER=smtp

to

MAIL_DRIVER=sendmail

And then clear cache with

php artisan config:cache

And everything went well

1

using laravel 7 and deployed on godaddys shared hosting.

just put this data in .env file and problem is solved

MAIL_MAILER=sendmail
MAIL_HOST=localhost
MAIL_PORT=25
MAIL_USERNAME="****@domain.com"
MAIL_PASSWORD="password"
MAIL_ENCRYPTION="tls"
MAIL_FROM_ADDRESS="****@domain.com"
MAIL_FROM_NAME="${APP_NAME}"
1
  • 1
    Please add some explanation to your answer such that others can learn from it
    – Nico Haase
    Commented Oct 16, 2021 at 15:15
0

It's the same happening with me. In local it's working fine but in the live server as am using the GoDaddy server same issue is araising continuously. but finally, it works. here are my codes below for the .env file.

MAIL_DRIVER=smtp
MAIL_HOST=abc.com
MAIL_PORT=25
[email protected]
MAIL_PASSWORD=******
MAIL_ENCRYPTION=

Hope it will work for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.