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

时间:2018-08-09 01:13:08

标签: 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'
  mailer_port: '587'
  mailer_smtp: 'smtp.office365.com'

2 个答案:

答案 0 :(得分:0)

我会尝试将'smtp.office365.com'粘贴到以下字段:mailer_host

答案 1 :(得分:0)

使用主机而不是mailer_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 }