-
Notifications
You must be signed in to change notification settings - Fork 938
Sending email via Office365
Giuseppe Modarelli edited this page Dec 25, 2015
·
2 revisions
When sending an email using office365 smtp the user_name
needs to be the same as the value used in the from
of the email. Otherwise you will get: Client does not have permissions to send as this sender
Mail.defaults do
delivery_method :smtp, {
address: 'smtp.office365.com',
port: 587,
user_name: ENV['OFFICE_365_SMTP_USER'],
password: ENV['OFFICE_365_SMTP_PASSWORD'],
authentication: :login,
encryption: :tls
}
end
mail = Mail.new do
from ENV['OFFICE_365_SMTP_USER'],
to '[email protected]'
subject 'This is a test email'
body 'This is a mail body'
end
mail.deliver