Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';t使用PHP和gmail smtp从本地web服务器发送邮件_Php_Smtp_Gmail_Swiftmailer - Fatal编程技术网

Can';t使用PHP和gmail smtp从本地web服务器发送邮件

Can';t使用PHP和gmail smtp从本地web服务器发送邮件,php,smtp,gmail,swiftmailer,Php,Smtp,Gmail,Swiftmailer,我想从我的本地服务器(Windows 10上的Laragon)发送一封带有Swift Mailer和gmail smtp的电子邮件 首先在我的Gmail帐户中: 已禁用2步验证 我为应用程序启用了较低的安全性 在我的PHP文件中,我创建了如下swift传输: //创建传输 $transport=(新的Swift_SmtpTransport('smtp.gmail.com',587',tls')) ->setUsername('*****@gmail.com') ->设置密码('******'

我想从我的本地服务器(Windows 10上的Laragon)发送一封带有Swift Mailer和gmail smtp的电子邮件

首先在我的Gmail帐户中:

  • 已禁用2步验证
  • 我为应用程序启用了较低的安全性
在我的PHP文件中,我创建了如下swift传输:

//创建传输
$transport=(新的Swift_SmtpTransport('smtp.gmail.com',587',tls'))
->setUsername('*****@gmail.com')
->设置密码('******')
;
然后发生了这个错误,我不明白:

Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed in F:\laragon\www\web-developer\PHP\PHP6-API\GmailAPI\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php on line 94

有什么想法吗?我必须为TLS激活Web服务器上的某些内容吗?

这是否回答了您的问题?非常感谢。它似乎与PHPMailer配合得很好,但还没有找到如何与swift-mailer配合使用的方法。