使用工匠命令发送电子邮件时

使用工匠命令发送电子邮件时

本文介绍了使用工匠命令发送电子邮件时,cURL错误60:SSL证书问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Laravel中发送电子邮件时,我遇到了一个奇怪的问题。

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

我使用Mailgun,可以在用户注册时发送电子邮件,并且类似的事情。

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

我开始使用调度命令,并创建了一个定制的artisan命令来获取一些记录并发送一些有关这些邮件的电子邮件。

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:

我已经建立了 cacert.pem 在本地并将其成功链接到我的 php.ini 文件中,这是我能够正常发送电子邮件的方式。

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.

我不明白为什么我的命令可以在控制器内部正常发送时为什么不能发送电子邮件。

这是我的代码用于命令:

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.

任何帮助您发送电子邮件的人将不胜感激。我使用WAMP来解决这个问题。

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

推荐答案

您可以修改供应商文件夹 GuzzleHttp\客户端 verify 键从 configureDefaults false c $ c>方法,就像我在本地计算机上所做的一样

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

您可以阅读,然后尝试在某些评论中下载 .pem 文件。

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

以下是一些链接:

  • .pem File Download

之后,您应该相应地编辑php.ini文件:

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

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

PS:我只编辑供应商文件,因为它速度更快,而且不难意识到。

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

这篇关于使用工匠命令发送电子邮件时,cURL错误60:SSL证书问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-21 01:37