Diffstat (limited to 'noncore/net/mail/libmailwrapper/smtpwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
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 @@ -3,12 +3,13 @@ #include <sys/types.h> #include <unistd.h> #include <fcntl.h> #include <string.h> #include <qdir.h> #include <qt.h> +#include <qmessagebox.h> #include <qpe/config.h> #include <qpe/qcopenvelope_qws.h> #include <libetpan/libetpan.h> @@ -551,12 +552,23 @@ void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) { free(from); } if (rcpts) 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("<center>%1</center>").arg(failuremessage)); + } +} + int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size, SMTPaccount *smtp ) { const char *server, *user, *pass; bool ssl; uint16_t port; mailsmtp *session; int err,result; @@ -586,18 +598,20 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size, SMT } else { qDebug( "No SSL session" ); err = mailsmtp_socket_connect( session, server, port ); } 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; } qDebug( "INIT OK" ); @@ -618,21 +632,29 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size, SMT } else { user = smtp->getUser().latin1(); pass = smtp->getPassword().latin1(); } 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; } qDebug( "Mail sent." ); |