【问题标题】:Problem in Send Mail using Swift Mailer using Office 365使用 Office 365 使用 Swift Mailer 发送邮件的问题
【发布时间】:2020-06-12 11:52:42
【问题描述】:

我尝试使用 Swift-mailer 服务发送邮件……我的组织使用 Outlook 365。 下面是配置。 $transport = (new \Swift_SmtpTransport('outlook.office365.com', 587,'tls'))

但我收到身份验证错误 我在gmail中试过。工作正常。我试过的端口号是 587 和 443 .. 两者都显示身份验证错误。有什么想法吗?

$transport = (new \Swift_SmtpTransport('smtp.office365.com', 587,'tls'))

未能使用 1 个可能的身份验证器在用户名“Username@Organization.com”的 SMTP 服务器上进行身份验证。身份验证器登录返回预期响应代码 235,但得到代码“535”,消息“535 5.7.3 身份验证不成功 [MAXPR0101CA0037.INDPRD01.PROD.OUTLOOK.COM] ”。

【问题讨论】:

    标签: php symfony swiftmailer


    【解决方案1】:

    您使用 symfony 还是使用独立的库?

    我很确定即使是独立版本也需要这部分:

    mailer_transport: smtp
    mailer_host: smtp.office365.com
    mailer_port: 587
    mailer_user: some-user@domain.tld
    mailer_password: some-password
    mailer_encryption: tls
    mailer_delivery_adress: some-email-adress-here
    

    基于快速浏览他们的文档

        // Create the Transport
    
    $transport = (new Swift_SmtpTransport('smtp.office365.com', 587))
      ->setUsername('your username')
      ->setPassword('your password')
    ;
    
    // Create the Mailer using your created Transport
    $mailer = new Swift_Mailer($transport);
    
    // Create a message
    $message = (new Swift_Message('Wonderful Subject'))
      ->setFrom(['john@doe.com' => 'John Doe'])
      ->setTo(['receiver@domain.org', 'other@domain.org' => 'A name'])
      ->setBody('Here is the message itself')
      ;
    
    // Send the message
    $result = $mailer->send($message);
    

    【讨论】:

    • 您好,感谢您的回复。我使用了 symfony 4 .4。我必须使用 mailer_transport: smtp mailer_host: smtp.office365.com mailer_port: 587 mailer_user: some-user@domain.tld mailer_password: some-password mailer_encryption: tls mailer_delivery_adress: some-email-adress-here
    猜你喜欢
    • 1970-01-01
    • 2021-12-09
    • 2011-01-30
    • 2016-10-18
    • 1970-01-01
    • 1970-01-01
    • 2022-11-24
    • 2012-09-05
    • 1970-01-01
    相关资源
    最近更新 更多