summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
index 00181ff..4764b77 100644
--- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
@@ -535,21 +535,21 @@ void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp )
if (from) {free(from);}
if (rcpts) smtp_address_list_free( rcpts );
}
int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size, SMTPaccount *smtp )
{
- char *server, *user, *pass;
+ const char *server, *user, *pass;
bool ssl;
uint16_t port;
mailsmtp *session;
int err,result;
result = 1;
server = user = pass = 0;
- server = strdup( smtp->getServer().latin1() );
+ server = smtp->getServer().latin1();
ssl = smtp->getSSL();
port = smtp->getPort().toUInt();
session = mailsmtp_new( 20, &progress );
if ( session == NULL ) goto free_mem;
@@ -558,39 +558,42 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size, SMT
qDebug( "SSL session" );
err = mailsmtp_ssl_connect( session, server, port );
} else {
qDebug( "No SSL session" );
err = mailsmtp_socket_connect( session, server, port );
}
- if ( err != MAILSMTP_NO_ERROR ) {result = 0;goto free_mem_session;}
+ if ( err != MAILSMTP_NO_ERROR ) {qDebug("Error init connection");result = 0;goto free_mem_session;}
err = mailsmtp_init( session );
if ( err != MAILSMTP_NO_ERROR ) {result = 0; goto free_con_session;}
qDebug( "INIT OK" );
if ( smtp->getLogin() ) {
+ qDebug("smtp with auth");
if ( smtp->getUser().isEmpty() || smtp->getPassword().isEmpty() ) {
// get'em
LoginDialog login( smtp->getUser(), smtp->getPassword(), NULL, 0, true );
login.show();
if ( QDialog::Accepted == login.exec() ) {
// ok
- user = strdup( login.getUser().latin1() );
- pass = strdup( login.getPassword().latin1() );
+ user = login.getUser().latin1();
+ pass = login.getPassword().latin1();
} else {
result = 0; goto free_con_session;
}
} else {
- user = strdup( smtp->getUser().latin1() );
- pass = strdup( smtp->getPassword().latin1() );
+ user = smtp->getUser().latin1();
+ pass = smtp->getPassword().latin1();
}
qDebug( "session->auth: %i", session->auth);
- err = mailsmtp_auth( session, user, pass );
+ err = mailsmtp_auth( session, (char*)user, (char*)pass );
if ( err == MAILSMTP_NO_ERROR ) qDebug("auth ok");
qDebug( "Done auth!" );
+ } else {
+ qDebug("SMTP without auth");
}
err = mailsmtp_send( session, from, rcpts, data, size );
if ( err != MAILSMTP_NO_ERROR ) {
qDebug("Error sending mail: %s",mailsmtpError(err).latin1());
result = 0; goto free_con_session;
@@ -601,17 +604,12 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size, SMT
free_con_session:
mailsmtp_quit( session );
free_mem_session:
mailsmtp_free( session );
free_mem:
- if (server) free( server );
- if ( smtp->getLogin() ) {
- free( user );
- free( pass );
- }
return result;
}
void SMTPwrapper::sendMail(const Mail&mail,SMTPaccount*aSmtp,bool later )
{
mailmime * mimeMail;