summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/smtpwrapper.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/kmicromail/libmailwrapper/smtpwrapper.cpp b/kmicromail/libmailwrapper/smtpwrapper.cpp
index 448a2e9..a6c12e4 100644
--- a/kmicromail/libmailwrapper/smtpwrapper.cpp
+++ b/kmicromail/libmailwrapper/smtpwrapper.cpp
@@ -198,94 +198,104 @@ void SMTPwrapper::connect_server()
QString failuretext = "";
if (m_smtp || !m_SmtpAccount) {
return;
}
server = m_SmtpAccount->getServer();
if ( m_SmtpAccount->ConnectionType() == 3 ) {
ssl = true;
try_tls = false;
} else if (m_SmtpAccount->ConnectionType() == 2) {
force_tls = true;
try_tls = true;
} else if (m_SmtpAccount->ConnectionType() == 1) {
try_tls = true;
}
int result = 1;
port = m_SmtpAccount->getPort().toUInt();
m_smtp = mailsmtp_new( 20, &progress );
if ( m_smtp == NULL ) {
/* no failure message cause this happens when problems with memory - than we
we can not display any messagebox */
return;
}
+ //m_smtp->auth = MAILSMTP_AUTH_LOGIN;
int err = MAILSMTP_NO_ERROR;
; // odebug << "Servername " << server << " at port " << port << "" << oendl;
if ( ssl ) {
qDebug("smtp: ssl_connect ");
err = mailsmtp_ssl_connect( m_smtp, server.latin1(), port );
} else {
; // odebug << "No SSL session" << oendl;
err = mailsmtp_socket_connect( m_smtp, server.latin1(), port );
}
if ( err != MAILSMTP_NO_ERROR ) {
qDebug("Error init SMTP connection" );
failuretext = i18n("Error init SMTP connection:\n%1").arg(mailsmtpError(err));
result = 0;
}
qDebug("SMTP connection inited ");
/* switch to tls after init 'cause there it will send the ehlo */
if (result) {
err = mailsmtp_init( m_smtp );
if (err != MAILSMTP_NO_ERROR) {
result = 0;
qDebug("Error init SMTP connection ");
failuretext = i18n("Error init SMTP connection:\n%1").arg(mailsmtpError(err));
}
}
if (result && try_tls) {
qDebug("Smpt: Try TLS... ");
err = start_smtp_tls();
if (err != MAILSMTP_NO_ERROR) {
try_tls = false;
qDebug("Smpt: No TLS possible ");
} else {
- err = mailesmtp_ehlo(m_smtp);
- if ( err != MAILSMTP_NO_ERROR )
- result = 0;
- else
- qDebug("Smpt: Using TLS ");
+ qDebug("Smpt: Using TLS ");
}
}
+
//qDebug("mailesmtp_ehlo %d ",err );
if (!try_tls && force_tls) {
result = 0;
failuretext = i18n("Error init SMTP tls:%1").arg(mailsmtpError(err));
+ }
+ if ( mailesmtp_ehlo(m_smtp) != MAILSMTP_NO_ERROR ) {
+ qDebug("Smpt: ehlo failed ");
+ result = 0;
}
-
+ else {
+ //qDebug("Smpt: auth is %d -- %d %d",m_smtp->auth, MAILSMTP_AUTH_LOGIN, MAILSMTP_AUTH_PLAIN);
+ if ( m_smtp->auth & MAILSMTP_AUTH_LOGIN && m_smtp->auth & MAILSMTP_AUTH_PLAIN ) {
+ qDebug("Smpt: Using MAILSMTP_AUTH_LOGIN ");
+ m_smtp->auth -= MAILSMTP_AUTH_PLAIN;
+ //qDebug("Smpt: auth is %d -- %d %d",m_smtp->auth, MAILSMTP_AUTH_LOGIN, MAILSMTP_AUTH_PLAIN);
+ }
+ }
+
if (result==1 && m_SmtpAccount->getLogin() ) {
; // odebug << "smtp with auth" << oendl;
if ( m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty() ) {
// get'em
LoginDialog login( m_SmtpAccount->getUser(),
m_SmtpAccount->getPassword(), NULL, 0, true );
login.show();
if ( QDialog::Accepted == login.exec() ) {
// ok
user = login.getUser();
pass = login.getPassword();
} else {
result = 0;
failuretext=i18n("Login aborted - \nstoring mail to localfolder");
}
} else {
user = m_SmtpAccount->getUser();
pass = m_SmtpAccount->getPassword();
}
; // odebug << "session->auth: " << m_smtp->auth << "" << oendl;
if (result) {
err = mailsmtp_auth( m_smtp, (char*)user.latin1(), (char*)pass.latin1() );
if ( err == MAILSMTP_NO_ERROR ) {
qDebug("Smtp authentification ok ");