https://bugs.kde.org/show_bug.cgi?id=421664
--- Comment #3 from Arne Spiegelhauer <gm2....@gmail.com> --- I have done some debugging and found a couple of issues in smtpjob.cpp (kmailtransport) and accountmanager.cpp (libkgapi). 1. When SmtpJob::startPasswordRetrieval(true) is executed and calls KGAPI2::AccountManager::instance()->refreshTokens after a successful findAccount, the AccountPromise created for findAccount has not yet been destroyed and is reused by the createPromise function. Since mRunning is true, the only action of refreshTokens is to return the AccountPromise, and since its emitFinished() has already been executed, nothing more happens. 2. When the previous AccountPromise is removed from the mPendingPromises hash table before refreshTokens is called, refresh succeeds and the mail is successfully sent to the SMTP server, but the mail is not deleted/moved from the outbox. This is due to a missing removeSubjob for the TokenExpired case in the SmtpJob::slotResult function, leading to the !hasSubjobs() condition for sending a noError result is not fulfilled. 3. loginJob:result is connected to SmtpJob::slotResult both explicitly and as a result of addSubJob, leading to SmtpJob::slotResult receiving duplicated result signals from loginJob. 4. Not really a problem, but an unsuccessful login attempt on expired token can be avoided by adopting the algorithm used in gmailpasswordrequester.cpp from kdepim-runtime. When refresh is not forced, gmailpasswordrequester calls KGAPI2::AccountManager::instance()->getAccount, which does a token refresh if a comparison between current time and calculated expiry time indicates that it is needed. 5. Not really related, but the code at the end of SmtpJob::startSmtpJob looks like it could start a password retrieval and a sendjob at the same time. -- You are receiving this mail because: You are watching all bug changes.