summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper
Unidiff
Diffstat (limited to 'kmicromail/libmailwrapper') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/smtpwrapper.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/kmicromail/libmailwrapper/smtpwrapper.cpp b/kmicromail/libmailwrapper/smtpwrapper.cpp
index 872a460..845c71c 100644
--- a/kmicromail/libmailwrapper/smtpwrapper.cpp
+++ b/kmicromail/libmailwrapper/smtpwrapper.cpp
@@ -241,20 +241,22 @@ void SMTPwrapper::connect_server()
241 if (err != MAILSMTP_NO_ERROR) { 241 if (err != MAILSMTP_NO_ERROR) {
242 result = 0; 242 result = 0;
243 qDebug("Error init SMTP connection "); 243 qDebug("Error init SMTP connection ");
244 failuretext = i18n("Error init SMTP connection:\n%1").arg(mailsmtpError(err)); 244 failuretext = i18n("Error init SMTP connection:\n%1").arg(mailsmtpError(err));
245 } 245 }
246 } 246 }
247 if (try_tls) { 247 if (result && try_tls) {
248 qDebug("Smpt: Try tls "); 248 qDebug("Smpt: Try tls ");
249 err = start_smtp_tls(); 249 err = start_smtp_tls();
250 if (err != MAILSMTP_NO_ERROR) { 250 if (err != MAILSMTP_NO_ERROR) {
251 try_tls = false; 251 try_tls = false;
252 qDebug("no tls "); 252 qDebug("no tls ");
253 } else { 253 } else {
254 err = mailesmtp_ehlo(m_smtp); 254 err = mailesmtp_ehlo(m_smtp);
255 if ( err != MAILSMTP_NO_ERROR )
256 result = 0;
255 } 257 }
256 } 258 }
257 //qDebug("mailesmtp_ehlo %d ",err ); 259 //qDebug("mailesmtp_ehlo %d ",err );
258 if (!try_tls && force_tls) { 260 if (!try_tls && force_tls) {
259 result = 0; 261 result = 0;
260 failuretext = i18n("Error init SMTP tls:%1").arg(mailsmtpError(err)); 262 failuretext = i18n("Error init SMTP tls:%1").arg(mailsmtpError(err));
@@ -287,12 +289,16 @@ void SMTPwrapper::connect_server()
287 } else { 289 } else {
288 failuretext = i18n("Authentification failed"); 290 failuretext = i18n("Authentification failed");
289 result = 0; 291 result = 0;
290 } 292 }
291 } 293 }
292 } 294 }
295 if ( result == 0 ) {
296 mailsmtp_free(m_smtp);
297 m_smtp = 0;
298 }
293} 299}
294 300
295void SMTPwrapper::disc_server() 301void SMTPwrapper::disc_server()
296{ 302{
297 if (m_smtp) { 303 if (m_smtp) {
298 mailsmtp_quit( m_smtp ); 304 mailsmtp_quit( m_smtp );
@@ -343,13 +349,17 @@ bool SMTPwrapper::sendMail(const Opie::Core::OSmartPointer<Mail>&mail,bool later
343 sendProgress->setMaxMails(1); 349 sendProgress->setMaxMails(1);
344 result = smtpSend( mimeMail,later); 350 result = smtpSend( mimeMail,later);
345 ; // odebug << "Clean up done" << oendl; 351 ; // odebug << "Clean up done" << oendl;
346 sendProgress->hide(); 352 sendProgress->hide();
347 delete sendProgress; 353 delete sendProgress;
348 sendProgress = 0; 354 sendProgress = 0;
349 mailmime_free( mimeMail ); 355 mailmime_free( mimeMail );
356 if ( m_smtp ) {
357 mailsmtp_free(m_smtp);
358 m_smtp = 0;
359 }
350 } 360 }
351 return result; 361 return result;
352} 362}
353 363
354int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,const RecMailP&which) { 364int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,const RecMailP&which) {
355 size_t curTok = 0; 365 size_t curTok = 0;
@@ -455,18 +465,23 @@ bool SMTPwrapper::flushOutbox() {
455 sendProgress->setCurrentMails(mailsToRemove.count()); 465 sendProgress->setCurrentMails(mailsToRemove.count());
456 } 466 }
457 if (reset_user_value) { 467 if (reset_user_value) {
458 m_SmtpAccount->setUser(oldUser); 468 m_SmtpAccount->setUser(oldUser);
459 m_SmtpAccount->setPassword(oldPw); 469 m_SmtpAccount->setPassword(oldPw);
460 } 470 }
471
461 KConfig cfg( locateLocal("config", "kopiemailrc" ) ); 472 KConfig cfg( locateLocal("config", "kopiemailrc" ) );
462 cfg.setGroup( "Status" ); 473 cfg.setGroup( "Status" );
463 m_queuedMail = mailsToSend.count(); 474 m_queuedMail = mailsToSend.count();
464 cfg.writeEntry( "outgoing", m_queuedMail ); 475 cfg.writeEntry( "outgoing", m_queuedMail );
465 emit queuedMails( m_queuedMail ); 476 emit queuedMails( m_queuedMail );
466 sendProgress->hide(); 477 sendProgress->hide();
467 delete sendProgress; 478 delete sendProgress;
468 sendProgress = 0; 479 sendProgress = 0;
469 wrap->deleteMails(mbox,mailsToRemove); 480 wrap->deleteMails(mbox,mailsToRemove);
470 delete wrap; 481 delete wrap;
482 if ( m_smtp ) {
483 mailsmtp_free(m_smtp);
484 m_smtp = 0;
485 }
471 return returnValue; 486 return returnValue;
472} 487}