【问题标题】:How can I send emails using Symfony, Swift Mailer, and Office 365?如何使用 Symfony、Swift Mailer 和 Office 365 发送电子邮件?
【发布时间】:2018-08-09 01:13:07
【问题描述】:

我正在使用部署在 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'

【问题讨论】:

  • 为了真正帮助您,您应该粘贴 swiftmailer 配置,而不是 parameters。确保这些值用于正确的设置。例如@NabilAfraz 的回答。

标签: symfony smtp office365 swiftmailer


【解决方案1】:

我会尝试为以下字段粘贴“smtp.office365.com”:mailer_host

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-11-03
      • 1970-01-01
      • 1970-01-01
      • 2022-11-24
      • 1970-01-01
      • 1970-01-01
      • 2022-09-24
      相关资源
      最近更新 更多