【问题标题】:SMTP settings for Office 365 in Rails applicationRails 应用程序中 Office 365 的 SMTP 设置
【发布时间】:2023-04-05 10:22:02
【问题描述】:

我在 Godaddy 有一个 Office 365 邮件帐户。我正在尝试为我的 Rails 应用设置 SMTP 设置:

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address              => "smtp.office365.com",
:port                 => 587,
:user_name            => ENV["OFFICE_USERNAME"],
:password             => ENV["OFFICE_PASSWORD"],
:authentication       => 'login',
:domain               => 'example.com',
:enable_starttls_auto => true  }

但是当我通过从我的联系页面提交消息来测试这些设置时,我收到以下错误消息:

550 5.7.1 客户端无权作为此发件人发送

如何在 Rails 应用程序中为 Office 365 帐户设置 SMTP 设置?

【问题讨论】:

    标签: ruby-on-rails email office365


    【解决方案1】:

    我在这里找到了这个问题的答案: http://www.brownwebdesign.com/blog/connecting-rails-to-microsoft-exchange-smtp-email-server

    相关部分:

    config.action_mailer.delivery_method = :smtp
    config.action_mailer.smtp_settings = {
      :address        => 'smtp.office365.com',
        :port           => '587',
        :authentication => :login,
        :user_name      => ENV['SMTP_USERNAME'],
        :password       => ENV['SMTP_PASSWORD'],
        :domain         => 'congrueit.com',
        :enable_starttls_auto => true
    }
    

    然后:

    确保发件人:电子邮件地址、发件人域和用户/密码匹配。

    不是我的工作,只是复制和粘贴对我有用的相关信息。

    2021 年的补充
    自 2020 年 4 月起,您必须在您的 office 336 组织您正在使用的邮件帐户中启用 SMTP AUTH。
    Enable ... SMPT AUTH at docs.ms。在本文档中,缺少必须启用这两个部分的说明。

    【讨论】:

    • 很好,但您应该在答案中写下相关部分,以防万一该链接有一天失效时丢失信息。
    • 您解决了我将 msmtp 与 Godaddy 365 SMTP 一起使用的问题,谢谢!
    • 我发现这很有用,谢谢。但我认为域部分在这里无关紧要。
    • 我可以确认域部分无关紧要。至少当它包含在 user_name 中时不需要它。
    猜你喜欢
    • 2018-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-25
    • 1970-01-01
    • 2016-02-11
    • 1970-01-01
    相关资源
    最近更新 更多