无法使用 Swift Mailer 在 Laravel 中发送电子邮件 - proc_open() 功能被提供商禁用

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

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

我收到此错误日志:

> proc_open() has been disabled for security reasons

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

检查并更改您的 php.ini 有此行。

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

检查这个被安全模式禁用的功能列表here

更新
找到后,请按照以下说明操作: 从 php.ini 文件

的 disable_functions 中删除 proc_open

如果您没有access/right删除上面的字符串,请让您的托管服务提供商删除。

proc_open 仅当 Swiftmailer 使用外部可执行文件(如 sendmail)时才需要。您应该仍然可以使用其他传输方式,例如 SMTP、Mailgun 或文档中描述的 one of the other drivers

作为测试,尝试使用 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)

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