Using SMTP relay via Office365 in Rails apps

First you’ll need to add your production box IP address to Exchange Connector

Example URL: https://outlook.office365.com/ecp/?rfr=Admin_o365&exsvurl=1&Realm=yourdomain.com

Then add the following to application production.rb

config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true 
config.action_mailer.smtp_settings = {         
  :address => "yourdomain-com.mail.protection.outlook.com",
  :from => 'somesendername@yourdomain.com',
  :port => 25,
  :domain => "yourdomain.com",
  :enable_starttls_auto => true    
}

and boom! your Rails app will start sending emails through Office 365.