I have an Office 365 mail account with Godaddy. I'm trying to setup the SMTP settings for my Rails app:
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 }
but when I test those settings by submitting a message from my contact page, I get this error message:
550 5.7.1 Client does not have permissions to send as this sender
How to set up the SMTP settings for an Office 365 account in a Rails application?
I found the answer to this question here: http://www.brownwebdesign.com/blog/connecting-rails-to-microsoft-exchange-smtp-email-server
Relevant parts:
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
}
Then:
make sure the from: email address matches, from domain, and user/pass.
Not my work just copy and paste of relevant information that worked for me.
Addition for 2021:
Since April 2020, you have to enable SMTP AUTH in your office 336 organisation and the mail account you are using.
See Enable ... SMPT AUTH at docs.ms. In this document, the explanation is missing that both parts must be enabled.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With