[isomorphic-core] fix sending on Office 365

Summary:
Fixed sending on Office 365
nodemailer needed a special tls flag beyond the standard SSL.
See: http://stackoverflow.com/questions/29812132/error-sending-email-using-nodemailer-via-office365-smtp-meanjs-scaffold

Test Plan: manual

Reviewers: juan, jackie, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D3541
This commit is contained in:
Evan Morikawa 2016-12-20 13:08:30 -08:00
parent 6bbceda709
commit 5015d105b8
2 changed files with 16 additions and 8 deletions

View file

@ -65,15 +65,19 @@ function credentialsForProvider({provider, settings, email}) {
const connectionSettings = {
imap_host: 'outlook.office365.com',
imap_port: 993,
smtp_host: 'smtp.office365.com',
smtp_port: 465,
ssl_required: true,
smtp_custom_config: {
host: 'smtp.office365.com',
port: 587,
secure: false,
tls: {ciphers: 'SSLv3'},
},
}
const connectionCredentials = {
imap_username: email,
imap_password: settings.password,
smtp_username: email,
smpt_password: settings.password,
smtp_password: settings.password,
}
return {connectionSettings, connectionCredentials}
}

View file

@ -116,12 +116,16 @@ module.exports = (sequelize, Sequelize) => {
smtpConfig() {
const {smtp_host, smtp_port, ssl_required} = this.connectionSettings;
const config = {
let config = {}
if (this.connectionSettings.smtp_custom_config) {
config = this.connectionSettings.smtp_custom_config
} else {
config = {
host: smtp_host,
port: smtp_port,
secure: ssl_required,
}
}
if (this.provider === "imap" || this.provider === "office365") {
const {smtp_username, smtp_password} = this.decryptedCredentials();
config.auth = { user: smtp_username, pass: smtp_password}