Net::SMTPAuthenticationError (535 5.7.3 使用 Action Mailer 和 office 365 电子邮件发送电子邮件时身份验证失败
Net::SMTPAuthenticationError (535 5.7.3 Authentication unsuccessful while sending email using Action Mailer and office 365 email
我的 production.rb 和 development.rb 上有此代码。
config.active_record.dump_schema_after_migration = false
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = { host: 'mydomain.com' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.office365.com',
port: '587',
authentication: 'login',
domain: 'mydomain.com',
user_name: "username@mydomain.com",
password: "password",
enable_starttls_auto: true,
openssl_verify_mode: 'none'
}
我正在尝试使用 action mailer 从我的 office 365 邮件帐户发送邮件。这会在本地主机上完美地发送邮件。但它在生产过程中引发了以下错误。我正在使用 digitalocean 服务器。
App 7718 stdout: [7bd99d32-f3c4-49c3-abfd-ff19fa7ddb8a] Completed 500 Internal Server Error in 8800ms (ActiveRecord: 1.6ms)
App 7718 stdout: [7bd99d32-f3c4-49c3-abfd-ff19fa7ddb8a]
App 7718 stdout: [7bd99d32-f3c4-49c3-abfd-ff19fa7ddb8a] Net::SMTPAuthenticationError (535 5.7.3 Authentication unsuccessful [CO2PR04CA0117.namprd04.prod.outlook.com]
我在 Google 上到处搜索,但大多数都有针对 gmail 而不是 office 的解决方案。所以,我找不到确切的问题。
ActionMailer::Base.smtp_settings = {
address: ENV['SMTP_ADDRESS'],
port: ENV['SMTP_PORT'],
domain: ENV['SMTP_DOMAIN'],
authentication: 'login',
enable_starttls_auto: true,
user_name: ENV['SMTP_USERNAME'],
password: ENV['SMTP_PASSWORD']
}
我已经有一个使用上述设置的 office 365 帐户。
The other thing that got me was you need to send from the actual account you're using to log in with. For example, don't send email from noreply@brownwebdesign.com and use support@brownwebdesign.com as your SMTP_USERNAME.
更多信息在这里:https://www.brownwebdesign.com/blog/connecting-rails-to-microsoft-exchange-smtp-email-server
我的 production.rb 和 development.rb 上有此代码。
config.active_record.dump_schema_after_migration = false
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = { host: 'mydomain.com' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.office365.com',
port: '587',
authentication: 'login',
domain: 'mydomain.com',
user_name: "username@mydomain.com",
password: "password",
enable_starttls_auto: true,
openssl_verify_mode: 'none'
}
我正在尝试使用 action mailer 从我的 office 365 邮件帐户发送邮件。这会在本地主机上完美地发送邮件。但它在生产过程中引发了以下错误。我正在使用 digitalocean 服务器。
App 7718 stdout: [7bd99d32-f3c4-49c3-abfd-ff19fa7ddb8a] Completed 500 Internal Server Error in 8800ms (ActiveRecord: 1.6ms) App 7718 stdout: [7bd99d32-f3c4-49c3-abfd-ff19fa7ddb8a]
App 7718 stdout: [7bd99d32-f3c4-49c3-abfd-ff19fa7ddb8a] Net::SMTPAuthenticationError (535 5.7.3 Authentication unsuccessful [CO2PR04CA0117.namprd04.prod.outlook.com]
我在 Google 上到处搜索,但大多数都有针对 gmail 而不是 office 的解决方案。所以,我找不到确切的问题。
ActionMailer::Base.smtp_settings = {
address: ENV['SMTP_ADDRESS'],
port: ENV['SMTP_PORT'],
domain: ENV['SMTP_DOMAIN'],
authentication: 'login',
enable_starttls_auto: true,
user_name: ENV['SMTP_USERNAME'],
password: ENV['SMTP_PASSWORD']
}
我已经有一个使用上述设置的 office 365 帐户。
The other thing that got me was you need to send from the actual account you're using to log in with. For example, don't send email from noreply@brownwebdesign.com and use support@brownwebdesign.com as your SMTP_USERNAME.
更多信息在这里:https://www.brownwebdesign.com/blog/connecting-rails-to-microsoft-exchange-smtp-email-server