mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Added idea to ask SMTP credentials on AUTH failure
This commit is contained in:
parent
24dbe4f197
commit
2656d362d6
2 changed files with 97 additions and 61 deletions
|
|
@ -489,17 +489,44 @@ export class ComposePopupView extends AbstractViewPopup {
|
|||
|
||||
if (!sSentFolder) {
|
||||
showScreenPopup(FolderSystemPopupView, [FolderType.Sent]);
|
||||
} else try {
|
||||
} else {
|
||||
const sendError = 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;
|
||||
|
||||
this.getMessageRequestParams(sSentFolder).then(params => {
|
||||
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');
|
||||
|
|
@ -510,10 +537,7 @@ export class ComposePopupView extends AbstractViewPopup {
|
|||
} else {
|
||||
params.signPassphrase && Passphrases.delete(identity);
|
||||
this.sendError(true);
|
||||
this.sendErrorDesc(
|
||||
getNotification(iError, data?.ErrorMessage, Notifications.CantSendMessage)
|
||||
+ "\n" + data?.ErrorMessageAdditional
|
||||
);
|
||||
sendFailed(iError, data);
|
||||
}
|
||||
} else {
|
||||
if (arrayLength(this.aDraftInfo) > 0) {
|
||||
|
|
@ -542,17 +566,14 @@ export class ComposePopupView extends AbstractViewPopup {
|
|||
params,
|
||||
30000
|
||||
);
|
||||
}).catch(e => {
|
||||
console.error(e);
|
||||
this.sendError(true);
|
||||
this.sendErrorDesc(e);
|
||||
this.sending(false);
|
||||
});
|
||||
};
|
||||
|
||||
this.getMessageRequestParams(sSentFolder)
|
||||
.then(sendMessage)
|
||||
.catch(sendError);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
this.sendError(true);
|
||||
this.sendErrorDesc(e);
|
||||
this.sending(false);
|
||||
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue