如何从运行Windows 10的本地计算机上使用Symfony 4 Swiftmailer发送电子邮件? [英] How to send emails with Symfony 4 Swiftmailer from a local machine running on Windows 10?
问题描述
我正在尝试使用Symfony 4,Wamp和伪造sendmail 发送电子邮件Windows 10但没有成功,我托管在 OVH 上.我想指定我在OVH上托管了一个站点,并在Symfony 2上运行了相同的参数,而Swiftmailer可以完美运行.
I'm trying to send emails with Symfony 4, Wamp and fake sendmail on Windows 10 but without success, I'm hosted on OVH. I want to specify that I have a site hosted on OVH with same parameters running on Symfony 2 and Swiftmailer works perfectly.
这是我的Swiftmailer Symfony .env行:
Here is my Symfony .env line for Swiftmailer:
MAILER_URL=smtp://smtp.dnimz.com:465?encryption=ssl&auth_mode=login&username=simslay@dnimz.com&password=***
这是我的Swiftmailer Symfony控制器的一部分:
Here is part of my Symfony controller for Swiftmailer:
$message = (new \Swift_Message('Hello Email'))
->setFrom(array($this->container->getParameter('mailer_user') => 'dnimz'))
->setTo($user->getEmail())
->setBody(
$this->renderView(
'emails/email_registration.html.twig',
array('username' => $user->getUsername())
),
'text/html'
);
try {
$this->get('mailer')->send($message);
$this->addFlash('notice', 'mail envoyé !');
} catch (\Exception $e) {
$this->addFlash(
'notice',
'<strong>Le message n\'a pu être envoyé !</strong>'
);
}
这是我来自假sendmail的sendmail.ini:
Here is my sendmail.ini from fake sendmail:
[sendmail]
smtp_server=smtp.dnimz.com
smtp_port=465
smtp_ssl=auto
error_logfile=error.log
auth_username=simslay@dnimz.com
auth_password=***
pop3_server=
pop3_username=
pop3_password=
force_sender=
force_recipient=
hostname=
这是我的php.ini邮件功能部分:
Here is my php.ini mail function part:
SMTP =smtp.dnimz.com
smtp_port =465
sendmail_from = "simslay@dnimz.com"
sendmail_path = "C:/wamp64/sendmail/sendmail.exe"
mail.add_x_header = On
发送电子邮件时,我收到以下警告和错误消息:
When sending the email, I've got this warnings and error:
[调试]警告:stream_socket_client():SSL操作失败,代码为1.OpenSSL错误消息: 错误:14090086:SSL例程:ssl3_get_server_certificate:证书验证失败
[debug] Warning: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed
2017-12-29T18:44:09 + 00:00 [debug]警告:stream_socket_client():无法启用加密
2017-12-29T18:44:09+00:00 [debug] Warning: stream_socket_client(): Failed to enable crypto
2017-12-29T18:44:09 + 00:00 [debug]警告:stream_socket_client():无法连接到ssl://smtp.dnimz.com:465(未知错误)
2017-12-29T18:44:09+00:00 [debug] Warning: stream_socket_client(): unable to connect to ssl://smtp.dnimz.com:465 (Unknown error)
2017-12-29T18:44:09 + 00:00 [错误]刷新电子邮件队列时发生异常:无法与主机smtp.dnimz.com [#0]建立连接
2017-12-29T18:44:09+00:00 [error] Exception occurred while flushing email queue: Connection could not be established with host smtp.dnimz.com [ #0]
我不知道为什么会出现这些错误?
I don't know why these errors occur?
推荐答案
您似乎没有安装OpenSSL或证书错误.我记得与Windows上Composer经常发生的第一个警告类似的问题.解决方案是安装丢失的证书(只需将其放在WAMP安装的certs文件夹中)即可.
It looks like you either don't have OpenSSL installed or there is a certificate error. I remember a similar issue as the first warning regularly occuring with composer on Windows. The solution was to install a missing certificate (just place it in your certs folder in your WAMP-installation).
供参考,请参阅:
- https://akrabat.com/ssl-certificate- Verification-on-php-5-6/
- 从packagist更新时,Composer更新失败
- https://github.com/composer/composer/issues/2798 #issuecomment-59812991
- https://akrabat.com/ssl-certificate-verification-on-php-5-6/
- Composer update fails while updating from packagist
- https://github.com/composer/composer/issues/2798#issuecomment-59812991
这篇关于如何从运行Windows 10的本地计算机上使用Symfony 4 Swiftmailer发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!