提问人:Leon 提问时间:1/12/2023 更新时间:1/12/2023 访问量:537
使用 Ruby on Rails 和 OAuth2 发送电子邮件 (Office 365)
Sending Email with Ruby on Rails and OAuth2 (Office 365)
问:
我们的应用程序建立在
- 红宝石 2.2.1p85
- 轨道 4.2.5
我们使用 ActionMailer 发送通知电子邮件。我依赖 ActionMailer 和 SMTP 的旧代码是:
ActionMailer::Base.smtp_settings = {
:address => "smtp.office365.com",
:port => 587,
:domain => "smtp.office365.com",
:authentication => :login,
:user_name => "MY_EMAIL_ADDRESS",
:password => "MY_PASSWORD",
:enable_starttls_auto => true
}
......
def general_mail (to, subject, content, attachmts = [] )
attachmts.each do |attachment|
attachments[File.basename(attachment)] = File.read(attachment, mode: 'rb')
end
mail(to: to, subject: subject) do |format|
format.text { render :text => content }
end
end
代码现在不起作用,因为旧的身份验证方法将被弃用并切换到 OAuth2。
有人可以帮我使通知电子邮件代码在 Oauth2 下再次工作吗?
非常感谢!
答: 暂无答案
评论
authentication: "XOAUTH2"