separate username/password for SMTP Auth
[claws.git] / src / smtp.c
index b5888b2cc654655c1cd654a726ca0da9df374a80..cbcc8f780ae617e35e48fcfd9cbf9284c9c2d722 100644 (file)
 static gint verbose = 1;
 static gchar smtp_response[MSGBUFSIZE];
 
-gint smtp_helo(SockInfo *sock, const char *hostname, gboolean use_smtp_auth)
+gint smtp_helo(SockInfo *sock, const gchar *hostname, gboolean esmtp)
 {
-       if (use_smtp_auth) {
-               sock_printf(sock, "EHLO %s\r\n", hostname);
-               if (verbose)
-                       log_print("ESMTP> EHLO %s\n", hostname);
-
-               return esmtp_ok(sock);
-       } else {
+       if (esmtp)
+               return esmtp_ehlo(sock, hostname);
+       else {
                sock_printf(sock, "HELO %s\r\n", hostname);
                if (verbose)
                        log_print("SMTP> HELO %s\n", hostname);
@@ -66,7 +62,8 @@ gint smtp_from(SockInfo *sock, const gchar *from,
                } else
                        authtype = SMTPAUTH_CRAM_MD5;
 
-               esmtp_auth(sock, authtype, userid, passwd, use_smtp_auth);
+               if (esmtp_auth(sock, authtype, userid, passwd) != SM_OK)
+                       return SM_AUTHFAIL;
        }
 
        if (strchr(from, '<'))
@@ -145,7 +142,8 @@ gint smtp_ok(SockInfo *sock)
                        log_print("SMTP< %s\n", smtp_response);
 
                if ((smtp_response[0] == '1' || smtp_response[0] == '2' ||
-                    smtp_response[0] == '3') && smtp_response[3] == ' ')
+                    smtp_response[0] == '3') &&
+                    (smtp_response[3] == ' ' || smtp_response[3] == '\0'))
                        return SM_OK;
                else if (smtp_response[3] != '-')
                        return SM_ERROR;