Session *smtp_session_new(const gchar *server, gushort port,
const gchar *domain,
const gchar *user, const gchar *pass,
- SSLType ssl_type,
- SMTPAuthType enable_auth_type)
+ SSLType ssl_type)
#else
Session *smtp_session_new(const gchar *server, gushort port,
const gchar *domain,
- const gchar *user, const gchar *pass,
- SMTPAuthType enable_auth_type)
+ const gchar *user, const gchar *pass)
#endif
{
SMTPSession *session;
domain = get_domain_name();
if (use_esmtp)
- val = smtp_ehlo(sock, domain, &avail_auth_type, enable_auth_type);
+ val = smtp_ehlo(sock, domain, &avail_auth_type);
else
val = smtp_helo(sock, domain);
if (val != SM_OK) {
sock_close(sock);
return NULL;
}
- val = smtp_ehlo(sock, domain, &avail_auth_type, enable_auth_type);
+ val = smtp_ehlo(sock, domain, &avail_auth_type);
if (val != SM_OK) {
log_warning(_("Error occurred while sending EHLO\n"));
sock_close(sock);
g_free(session->pass);
}
-gint smtp_from(SMTPSession *session, const gchar *from)
+gint smtp_from(SMTPSession *session, const gchar *from,
+ SMTPAuthType forced_auth_type)
{
gchar buf[MSGBUFSIZE];
g_return_val_if_fail(from != NULL, SM_ERROR);
if (session->user) {
- if (smtp_auth(session) != SM_OK)
+ if (smtp_auth(session, forced_auth_type) != SM_OK)
return SM_AUTHFAIL;
}
return smtp_ok(SESSION(session)->sock, NULL, 0);
}
-gint smtp_auth(SMTPSession *session)
+gint smtp_auth(SMTPSession *session, SMTPAuthType forced_auth_type)
{
gchar buf[MSGBUFSIZE];
SMTPAuthType authtype = 0;
sock = SESSION(session)->sock;
- if ((session->avail_auth_type & SMTPAUTH_CRAM_MD5) != 0 &&
+ if ((forced_auth_type == SMTPAUTH_CRAM_MD5 ||
+ (forced_auth_type == 0 &&
+ (session->avail_auth_type & SMTPAUTH_CRAM_MD5) != 0)) &&
smtp_auth_cram_md5(sock, buf, sizeof(buf)) == SM_OK)
authtype = SMTPAUTH_CRAM_MD5;
- else if ((session->avail_auth_type & SMTPAUTH_LOGIN) != 0 &&
+ else if ((forced_auth_type == SMTPAUTH_LOGIN ||
+ (forced_auth_type == 0 &&
+ (session->avail_auth_type & SMTPAUTH_LOGIN) != 0)) &&
smtp_auth_login(sock, buf, sizeof(buf)) == SM_OK)
authtype = SMTPAUTH_LOGIN;
else {
}
gint smtp_ehlo(SockInfo *sock, const gchar *hostname,
- SMTPAuthType *avail_auth_type,
- SMTPAuthType enable_auth_type)
+ SMTPAuthType *avail_auth_type)
{
gchar buf[MSGBUFSIZE];
if (strncmp(buf, "250-", 4) == 0) {
gchar *p = buf;
p += 4;
-
- if (g_strncasecmp(p, "AUTH ", 5) == 0 ||
- (g_strncasecmp(p, "AUTH=", 5) == 0)) { /* CLAWS: qmail */
+ if (g_strncasecmp(p, "AUTH", 4) == 0) {
p += 5;
- if (strcasestr(p, "LOGIN") && (enable_auth_type & SMTPAUTH_LOGIN))
+ if (strcasestr(p, "LOGIN"))
*avail_auth_type |= SMTPAUTH_LOGIN;
- if (strcasestr(p, "CRAM-MD5") && (enable_auth_type & SMTPAUTH_CRAM_MD5))
+ if (strcasestr(p, "CRAM-MD5"))
*avail_auth_type |= SMTPAUTH_CRAM_MD5;
- if (strcasestr(p, "DIGEST-MD5") && (enable_auth_type & SMTPAUTH_DIGEST_MD5))
+ if (strcasestr(p, "DIGEST-MD5"))
*avail_auth_type |= SMTPAUTH_DIGEST_MD5;
}
} else if ((buf[0] == '1' || buf[0] == '2' || buf[0] == '3') &&