mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-11 02:30:21 +08:00
[iso-core] Fix Office365 sending from the mail app
Summary: This fixes a regression introduced in D3980 that prevented sending from working on Office365 and generic IMAP accounts. Fixes T7892 Test Plan: manual - we could use unit tests for this but need to set up tests for iso-core first Reviewers: juan, halla, evan Reviewed By: halla, evan Maniphest Tasks: T7892 Differential Revision: https://phab.nylas.com/D4003
This commit is contained in:
parent
1485575e48
commit
ee5abf22eb
2 changed files with 12 additions and 9 deletions
|
@ -71,9 +71,9 @@ function credentialsForProvider({provider, settings, email}) {
|
|||
|
||||
const connectionCredentials = {
|
||||
imap_username: email,
|
||||
imap_password: settings.password,
|
||||
imap_password: settings.password || settings.imap_password,
|
||||
smtp_username: email,
|
||||
smtp_password: settings.password,
|
||||
smtp_password: settings.password || settings.smtp_password,
|
||||
}
|
||||
return {connectionSettings, connectionCredentials}
|
||||
} else if (SUPPORTED_PROVIDERS.has(provider)) {
|
||||
|
|
|
@ -117,21 +117,24 @@ module.exports = (sequelize, Sequelize) => {
|
|||
},
|
||||
|
||||
smtpConfig() {
|
||||
// We always call credentialsForProvider() here because n1Cloud
|
||||
// sometimes needs to send emails for accounts which did not have their
|
||||
// full SMTP settings saved to the database.
|
||||
const {connectionSettings, connectionCredentials} = credentialsForProvider({
|
||||
provider: this.provider,
|
||||
settings: this.decryptedCredentials(),
|
||||
settings: Object.assign({}, this.decryptedCredentials(), this.connectionSettings),
|
||||
email: this.emailAddress,
|
||||
});
|
||||
const {smtp_host, smtp_port, smtp_username, ssl_required} = connectionSettings;
|
||||
let config = {}
|
||||
let config;
|
||||
const {smtp_host, smtp_port, ssl_required} = connectionSettings;
|
||||
if (connectionSettings.smtp_custom_config) {
|
||||
config = connectionSettings.smtp_custom_config
|
||||
config = connectionSettings.smtp_custom_config;
|
||||
} else {
|
||||
config = {
|
||||
host: smtp_host,
|
||||
port: smtp_port,
|
||||
secure: ssl_required,
|
||||
}
|
||||
};
|
||||
}
|
||||
if (this.provider === 'gmail') {
|
||||
const {xoauth2} = connectionCredentials;
|
||||
|
@ -139,9 +142,9 @@ module.exports = (sequelize, Sequelize) => {
|
|||
throw new Error("Missing XOAuth2 Token")
|
||||
}
|
||||
const token = this.bearerToken(xoauth2);
|
||||
config.auth = { user: smtp_username, xoauth2: token }
|
||||
config.auth = { user: connectionSettings.smtp_username, xoauth2: token }
|
||||
} else if (SUPPORTED_PROVIDERS.has(this.provider)) {
|
||||
const {smtp_password} = connectionCredentials
|
||||
const {smtp_username, smtp_password} = connectionCredentials
|
||||
config.auth = { user: smtp_username, pass: smtp_password}
|
||||
} else {
|
||||
throw new Error(`${this.provider} not yet supported`)
|
||||
|
|
Loading…
Reference in a new issue