简体   繁体   English

Mailgun:如何从我的本地机器(Laravel)发送电子邮件

[英]Mailgun: How can send email from my local machine (Laravel)

I have setup Mailgun on my Laravel project, the project will be deployed on a (Lan based) local server which hopefully connected to internet, email should be sent from the local machine where the project is being hosted, it works great on my dev server but when I try to send email from my local machine it returns below error.我已经在我的 Laravel 项目上设置了 Mailgun,该项目将部署在一个(基于 LAN 的)本地服务器上,该服务器希望连接到互联网,电子邮件应该从托管项目的本地机器发送,它在我的开发服务器上运行良好但是当我尝试从本地机器发送电子邮件时,它返回以下错误。

在此处输入图片说明

cURL error 60: SSL cert issue when sending email with artisan command cURL 错误 60:使用 artisan 命令发送电子邮件时出现 SSL 证书问题

You can either modify the vendor folder GuzzleHttp\\Client change verify key to false from configureDefaults method as I did in my local machine您可以修改供应商文件夹GuzzleHttp\\Clientverify密钥从configureDefaults方法更改为false ,就像我在本地机器上所做的那样

or或者

You can read this conversation in Laracasts and try downloading the .pem files in some of the comments.您可以在 Laracasts 中阅读此对话,并尝试在某些评论中下载.pem文件。

Here are some links:以下是一些链接:

After that you should edit your php.ini file accordingly:之后,您应该相应地编辑 php.ini 文件:

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

PS: I would just edit the vendor file, because it's much faster and not hard to realize. PS:我只会编辑供应商文件,因为它更快而且不难实现。

The reason is because the mailgun/guzzleHttp looking for valid certificate (SSL issue) for security reasons.原因是 mailgun/guzzleHttp 出于安全原因寻找有效证书(SSL 问题)。 You can solve it like below (Wamp server):你可以像下面这样解决它(Wamp服务器):

1- Download this file from http://curl.haxx.se/ca/cacert.pem and put this in "C:/wamp64/bin/php/(your php version)/extras/ssl/" directory 1- 从http://curl.haxx.se/ca/cacert.pem下载此文件并将其放在"C:/wamp64/bin/php/(your php version)/extras/ssl/"目录中

2- find all php.ini files (even php.ini-production and php.ini-development ) under this directory "C:/wamp64/bin/php/php (your php version)" 2- 在此目录"C:/wamp64/bin/php/php (your php version)"下找到所有php.ini文件(甚至php.ini-productionphp.ini-development

3- find these following parts in above .ini files and edit it as shown: 3- 在上面的.ini文件中找到以下这些部分并按如下所示进行编辑:

curl.cainfo = "C:/wamp64/bin/php/(your php version)/extras/ssl/cacert.pem"
openssl.cafile= "C:/wamp64/bin/php/(your php version)/extras/ssl/cacert.pem"

4- clear cache laravel and restart your laravel server 4-清除缓存laravel并重新启动laravel服务器

5- restart wamp server 5-重启wamp服务器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM