From c384fb58ea944d6430777d403a6462429242c59b Mon Sep 17 00:00:00 2001 From: alwin Date: Sun, 11 Jan 2004 11:45:10 +0000 Subject: when failure sending mails them will be stored into a local folder and a message box appears. --- (limited to 'noncore/net/mail') diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp index 085d5e4..7671133 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -554,6 +555,17 @@ void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) { smtp_address_list_free( rcpts ); } +void SMTPwrapper::storeFailedMail(const char*data,unsigned int size, const char*failuremessage) +{ + if (data) { + storeMail(data,size,"Sendfailed"); + } + if (failuremessage) { + QMessageBox::critical(0,tr("Error sending mail"), + tr("
%1
").arg(failuremessage)); + } +} + int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size, SMTPaccount *smtp ) { const char *server, *user, *pass; bool ssl; @@ -589,12 +601,14 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size, SMT } if ( err != MAILSMTP_NO_ERROR ) { qDebug("Error init connection"); + storeFailedMail(data,size,mailsmtpError(err)); result = 0; goto free_mem_session; } err = mailsmtp_init( session ); if ( err != MAILSMTP_NO_ERROR ) { + storeFailedMail(data,size,mailsmtpError(err)); result = 0; goto free_con_session; } @@ -621,15 +635,23 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size, SMT } qDebug( "session->auth: %i", session->auth); err = mailsmtp_auth( session, (char*)user, (char*)pass ); - if ( err == MAILSMTP_NO_ERROR ) + if ( err == MAILSMTP_NO_ERROR ) { qDebug("auth ok"); + } else { + storeFailedMail(data,size,tr("Authentification failed")); + result = 0; + goto free_con_session; + } qDebug( "Done auth!" ); } else { qDebug("SMTP without auth"); + result = 0; + goto free_con_session; } err = mailsmtp_send( session, from, rcpts, data, size ); if ( err != MAILSMTP_NO_ERROR ) { + storeFailedMail(data,size,mailsmtpError(err)); qDebug("Error sending mail: %s",mailsmtpError(err).latin1()); result = 0; goto free_con_session; diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.h b/noncore/net/mail/libmailwrapper/smtpwrapper.h index 7dcdbfd..89826d9 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.h +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.h @@ -60,6 +60,7 @@ protected: Settings *settings; int sendQueuedMail(AbstractMail*wrap,SMTPaccount*smtp,RecMail*which); + void storeFailedMail(const char*data,unsigned int size, const char*failuremessage); int m_queuedMail; static const char* USER_AGENT; -- cgit v0.9.0.2