cURL error 60: SSL cert issue when sending email with artisan command

- 1 answer

Ad

I have a weird issue going on with sending emails in Laravel.

I use Mailgun and can send emails fine when users register and everything like that.

I'm beginning to play around with scheduling commands and have created a custom artisan command to get some records and send some emails for these.

However when I run this command I get an error:

cURL error 60: SSL certificate problem: unable to get local issuer certificate

I have set up a cacert.pem locally and linked this successfully in my php.ini file which is how I am able to send emails normally.

I don't understand why my command cannot send emails when I can send them just fine inside a controller.

This is the code I am using for the command:

$reminders = Reminder::where('utcReminderDate' , '<=', \Carbon\Carbon::now()->format('Y-m-d H:i'))->get();

foreach($reminders as $reminder)
    {
        Mail::send('emails.test', [], function($message) {
            $message->to('[email protected]', 'Joe Bloggs');
            $message->subject('A reminder for you');
        });
    }

I'm wanting to get all the reminders that need to be sent and loop through them to send them out.

When I run the command to test it via command line, it spits out the error above.

Any help getting the emails to send would be hugely appreciated. I use WAMP if that makes a difference.

Ad

Answer

Ad

You can either modify the vendor folder GuzzleHttp\Client change verify key to false from configureDefaults method as I did in my local machine

or

You can read this conversation in Laracasts and try downloading the .pem files in some of the comments.

Here are some links:

After that you should edit your php.ini file accordingly:

curl.cainfo = "[pathtothisfile]\cacert.pem"

PS: I would just edit the vendor file, because it's much faster and not hard to realize.

Ad
source: stackoverflow.com
Ad