无法使用 Swift Mailer 在 Laravel 中发送电子邮件 - 提供程序禁用了 proc_open() 函数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45854659/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 16:32:35  来源:igfitidea点击:

Unable to send emails in Laravel using Swift Mailer - proc_open() function disabled by the provider

laravelswiftmailer

提问by robcaa

My web host disabled proc_openfunction in php and I can't send emails anymore.

我的网络主机在 php 中禁用了proc_open功能,我无法再发送电子邮件。

I get this error log:

我收到此错误日志:

proc_open() has been disabled for security reasons

出于安全原因,proc_open() 已被禁用

I use laravel default Swiftmailer. What can I do?

我使用 laravel 默认的 Swiftmailer。我能做什么?

回答by Don't Panic

proc_openshould only be required when Swiftmailer is using an external executable, like sendmail. You should still be able to use a different transport like SMTP, Mailgun, or one of the other driversdescribed in the docs.

proc_open只有当 Swiftmailer 使用外部可执行文件时才需要,比如 sendmail。您仍然应该能够使用不同的传输方式,例如 SMTP、Mailgun 或文档中描述的其他驱动程序之一。

As a test, try using the SMTP driver, and just entering your own SMTP mail details - whatever you use to send mail from your mail client. Try the following in your .env:

作为测试,尝试使用 SMTP 驱动程序,只需输入您自己的 SMTP 邮件详细信息 - 无论您使用什么从邮件客户端发送邮件。在您的.env:

MAIL_DRIVER=smtp
MAIL_HOST=your.smtp.host // (copy from your mail client)
MAIL_PORT=your.smtp.port // (copy from your mail client)
MAIL_USERNAME=your.smtp.username // (copy from your mail client)
MAIL_PASSWORD=your.smtp.password // (copy from your mail client)

This is probably not suitable for a permanent solution but will let you test that you can send mail without proc_open. I use the free tier of Mailgun and can recommend it.

这可能不适合永久解决方案,但可以让您测试是否可以在没有 proc_open 的情况下发送邮件。我使用 Mailgun 的免费层,可以推荐它。

回答by AddWeb Solution Pvt Ltd

Check and changes are your php.inihas this line.

检查和更改是您php.ini有这条线。

disable_functions = exec,system,dl,passthru,chown,shell_exec,popen,proc_open

Check this a list of functions disabled by safe mode here.

在此处检查安全模式禁用的功能列表。

UPDATE
Once you found that, follow below instruction: Remove the proc_openfrom the disable_functions at php.inifile

更新
一旦发现,请按照以下说明操作:从文件中的 disable_functions 中删除proc_openphp.ini

OR

或者

Ask your hosting provider to remove the string above if you don't have an access/right to do that.

如果您没有访问权限/权限,请要求您的托管服务提供商删除上面的字符串。