mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-06-28 06:46:27 +00:00
Added idea to ask SMTP credentials on AUTH failure
This commit is contained in:
@@ -489,70 +489,91 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||
|
||||
if (!sSentFolder) {
|
||||
showScreenPopup(FolderSystemPopupView, [FolderType.Sent]);
|
||||
} else try {
|
||||
this.sendError(false);
|
||||
this.sending(true);
|
||||
|
||||
sSentFolder = UNUSED_OPTION_VALUE === sSentFolder ? '' : sSentFolder;
|
||||
|
||||
this.getMessageRequestParams(sSentFolder).then(params => {
|
||||
Remote.request('SendMessage',
|
||||
(iError, data) => {
|
||||
this.sending(false);
|
||||
if (iError) {
|
||||
if (Notifications.CantSaveMessage === iError) {
|
||||
this.sendSuccessButSaveError(true);
|
||||
let msg = i18n('COMPOSE/SAVED_ERROR_ON_SEND');
|
||||
if (data?.ErrorMessageAdditional) {
|
||||
msg = msg + "\n" + data?.ErrorMessageAdditional;
|
||||
}
|
||||
this.savedErrorDesc(msg);
|
||||
} else {
|
||||
params.signPassphrase && Passphrases.delete(identity);
|
||||
this.sendError(true);
|
||||
this.sendErrorDesc(
|
||||
getNotification(iError, data?.ErrorMessage, Notifications.CantSendMessage)
|
||||
+ "\n" + data?.ErrorMessageAdditional
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (arrayLength(this.aDraftInfo) > 0) {
|
||||
const flag = {
|
||||
'reply': '\\answered',
|
||||
'forward': '$forwarded'
|
||||
}[this.aDraftInfo[0]];
|
||||
if (flag) {
|
||||
const aFlags = oLastMessage.flags();
|
||||
if (aFlags.indexOf(flag) === -1) {
|
||||
aFlags.push(flag);
|
||||
oLastMessage.flags(aFlags);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.close();
|
||||
}
|
||||
setFolderETag(this.draftsFolder(), '');
|
||||
setFolderETag(sSentFolder, '');
|
||||
if (3 === arrayLength(this.aDraftInfo)) {
|
||||
const folder = this.aDraftInfo[2];
|
||||
setFolderETag(folder, '');
|
||||
}
|
||||
reloadDraftFolder();
|
||||
},
|
||||
params,
|
||||
30000
|
||||
);
|
||||
}).catch(e => {
|
||||
} else {
|
||||
const sendError = e => {
|
||||
console.error(e);
|
||||
this.sendError(true);
|
||||
this.sendErrorDesc(e);
|
||||
this.sending(false);
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
this.sendError(true);
|
||||
this.sendErrorDesc(e);
|
||||
this.sending(false);
|
||||
};
|
||||
const sendFailed = (iError, data) => {
|
||||
this.sendError(true);
|
||||
this.sendErrorDesc(
|
||||
getNotification(iError, data?.ErrorMessage, Notifications.CantSendMessage)
|
||||
+ "\n" + data?.ErrorMessageAdditional
|
||||
);
|
||||
};
|
||||
try {
|
||||
this.sendError(false);
|
||||
this.sending(true);
|
||||
|
||||
sSentFolder = UNUSED_OPTION_VALUE === sSentFolder ? '' : sSentFolder;
|
||||
|
||||
const sendMessage = params => {
|
||||
Remote.request('SendMessage',
|
||||
(iError, data) => {
|
||||
this.sending(false);
|
||||
if (iError) {
|
||||
/*
|
||||
if (Notifications.AuthError === iError && !params.auth) {
|
||||
AskPopupView.password('SMTP login', 'retry', 3).then(result => {
|
||||
if (result) {
|
||||
this.sending(true);
|
||||
params.auth = result;
|
||||
sendMessage(params);
|
||||
} else {
|
||||
sendFailed(iError, data);
|
||||
}
|
||||
});
|
||||
} else
|
||||
*/
|
||||
if (Notifications.CantSaveMessage === iError) {
|
||||
this.sendSuccessButSaveError(true);
|
||||
let msg = i18n('COMPOSE/SAVED_ERROR_ON_SEND');
|
||||
if (data?.ErrorMessageAdditional) {
|
||||
msg = msg + "\n" + data?.ErrorMessageAdditional;
|
||||
}
|
||||
this.savedErrorDesc(msg);
|
||||
} else {
|
||||
params.signPassphrase && Passphrases.delete(identity);
|
||||
this.sendError(true);
|
||||
sendFailed(iError, data);
|
||||
}
|
||||
} else {
|
||||
if (arrayLength(this.aDraftInfo) > 0) {
|
||||
const flag = {
|
||||
'reply': '\\answered',
|
||||
'forward': '$forwarded'
|
||||
}[this.aDraftInfo[0]];
|
||||
if (flag) {
|
||||
const aFlags = oLastMessage.flags();
|
||||
if (aFlags.indexOf(flag) === -1) {
|
||||
aFlags.push(flag);
|
||||
oLastMessage.flags(aFlags);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.close();
|
||||
}
|
||||
setFolderETag(this.draftsFolder(), '');
|
||||
setFolderETag(sSentFolder, '');
|
||||
if (3 === arrayLength(this.aDraftInfo)) {
|
||||
const folder = this.aDraftInfo[2];
|
||||
setFolderETag(folder, '');
|
||||
}
|
||||
reloadDraftFolder();
|
||||
},
|
||||
params,
|
||||
30000
|
||||
);
|
||||
};
|
||||
|
||||
this.getMessageRequestParams(sSentFolder)
|
||||
.then(sendMessage)
|
||||
.catch(sendError);
|
||||
} catch (e) {
|
||||
sendError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +157,18 @@ trait Messages
|
||||
public function DoSendMessage() : array
|
||||
{
|
||||
$oAccount = $this->initMailClientConnection();
|
||||
|
||||
/*
|
||||
$aAuth = $this->GetActionParam('auth', null);
|
||||
if ($aAuth) {
|
||||
$oAccount->setSmtpUser($aAuth['username']);
|
||||
$oAccount->setSmtpPass(new \SnappyMail\SensitiveString($aAuth['password']));
|
||||
// if ($oAccount instanceof AdditionalAccount && !empty($aAuth['remember'])) {
|
||||
// $oMainAccount = $this->getMainAccountFromToken();
|
||||
// $aAccounts = $this->GetAccounts($oMainAccount);
|
||||
// $this->SetAccounts($oMainAccount, $aAccounts);
|
||||
// }
|
||||
}
|
||||
*/
|
||||
$oConfig = $this->Config();
|
||||
|
||||
$sSaveFolder = $this->GetActionParam('saveFolder', '');
|
||||
@@ -300,6 +311,10 @@ trait Messages
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (\MailSo\Smtp\Exceptions\LoginBadCredentialsException $oException)
|
||||
{
|
||||
throw new ClientException(Notifications::AuthError, $oException);
|
||||
}
|
||||
catch (ClientException $oException)
|
||||
{
|
||||
throw $oException;
|
||||
|
||||
Reference in New Issue
Block a user