php - Symfony,组件 Mailer Error 发送邮件
问题描述
在我的项目 Symfony 中,我使用 Mailer 组件发送电子邮件,但我发现了这个错误
无法与主机“ssl://smtp.gmail.com:465”建立连接:stream_socket_client():无法连接到 ssl://smtp.gmail.com:465(Une tentative de connexion a échoué car le parti connecté n'a pas répondu convenablement au-delà d'une certaine durée ou une connexion établie a échoué car l'hôte de connexion n'a pas répondu。
控制器中的代码php:
/**
* @Route("/send", name="send.mail")
*/
public function testSendMail(MailerInterface $mailer): Response{
$email = (new Email())
->from('test@gmail.com')
->to('test1@gmail.com')
//->cc('cc@example.com')
//->bcc('bcc@example.com')
//->replyTo('fabien@example.com')
//->priority(Email::PRIORITY_HIGH)
->subject('Time for Symfony Mailer!')
->text('Sending emails is fun again!')
->html('<p>See Twig integration for better HTML integration!</p>');
$mailer->send($email);
return new Response('send');
}
.env 文件中的代码配置:
MAILER_DSN=gmail://test@gmail.com:testpwd@localhost?encryption=tls&auth_mode=oauth
如何准确配置发送邮件
解决方案
推荐阅读
- microsoft-graph-api - Microsoft Graph 托管内容 ID 包含斜杠
- javascript - 使用 ReactJs 在电子商务网站中过滤性别
- firebase - 通过静态 IP 地址连接到 Firebase Functions
- reactjs - 为什么 console.log 显示正确的数组但状态错误(ReactJS)
- excel - 在 Angular 5 中将 XLSX 列数据类型更改为数字
- django - 如何正确过滤 Django 中的类别?
- r - 在 R 中使用 cplot() 绘制边际效应时出错
- python - 基于字符串值 Plotly Python 的标记颜色
- botframework - Teams Bot 获取使用
- c# - xamarin:Device.BeginInvokeOnMainThread 和 MainThread.BeginInvokeOnMainThread 之间的区别