Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.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
如何使用Symfony、Swift Mailer和Office 365发送电子邮件?_Symfony_Smtp_Office365_Swiftmailer - Fatal编程技术网

如何使用Symfony、Swift Mailer和Office 365发送电子邮件?

如何使用Symfony、Swift Mailer和Office 365发送电子邮件?,symfony,smtp,office365,swiftmailer,Symfony,Smtp,Office365,Swiftmailer,我正在使用部署在HostGator中的Symfony 3.4。在某些情况下,我需要向我的用户发送电子邮件。如果我使用Gmail,电子邮件会毫无问题地发送,但当我使用Office 365时,我会收到以下错误: 无法与主机建立连接 这是我的电子邮件配置: parameters: mailer_transport: smtp mailer_host: '' mailer_user: example@mydomain.co mailer_password: 'mypassword'

我正在使用部署在HostGator中的Symfony 3.4。在某些情况下,我需要向我的用户发送电子邮件。如果我使用Gmail,电子邮件会毫无问题地发送,但当我使用Office 365时,我会收到以下错误:

无法与主机建立连接

这是我的电子邮件配置:

parameters:
  mailer_transport: smtp
  mailer_host: ''
  mailer_user: example@mydomain.co
  mailer_password: 'mypassword'
  mailer_port: '587'
  mailer_smtp: 'smtp.office365.com'

我会尝试为字段粘贴“smtp.office365.com”:mailer\u host

使用host而不是mailer\u smtp。我的swiftmailer有这个配置。希望对你有用

# Swiftmailer Configuration
swiftmailer:
    transport: 'smtp'
    host: '%mailer_host%' //  in your case : 'smtp.office365.com'
    username: '%mailer_user%'
    password: '%mailer_password%'
    spool: { type: memory }

要真正帮助您,您应该粘贴
swiftmailer
配置,而不是
参数
。确保这些值用于正确的设置。例如@NabilAfraz的答案。