2004-11-26 [colin] 0.9.12cvs173.1
[claws.git] / src / common / smtp.c
index dd3f069e446a72ffdf3de2992b20e45905c1b7a7..346c63e5f4eae85ffcb431e99fc3023b00976fcc 100644 (file)
@@ -119,18 +119,29 @@ static void smtp_session_destroy(Session *session)
 static gint smtp_from(SMTPSession *session)
 {
        gchar buf[MSGBUFSIZE];
+       gchar *mail_size = NULL;
 
        g_return_val_if_fail(session->from != NULL, SM_ERROR);
 
        session->state = SMTP_FROM;
+       
+       if (session->is_esmtp)
+               mail_size = g_strdup_printf(" SIZE=%d", session->send_data_len);
+       else
+               mail_size = g_strdup("");
+               
 
        if (strchr(session->from, '<'))
-               g_snprintf(buf, sizeof(buf), "MAIL FROM:%s", session->from);
+               g_snprintf(buf, sizeof(buf), "MAIL FROM:%s%s", session->from,
+                          mail_size);
        else
-               g_snprintf(buf, sizeof(buf), "MAIL FROM:<%s>", session->from);
+               g_snprintf(buf, sizeof(buf), "MAIL FROM:<%s>%s", session->from,
+                          mail_size);
+
+       g_free(mail_size);
 
        session_send_msg(SESSION(session), SESSION_MSG_NORMAL, buf);
-       log_print("SMTP> %s\n", buf);
+       log_print("%sSMTP> %s\n", (session->is_esmtp?"E":""), buf);
 
        return SM_OK;
 }
@@ -269,7 +280,7 @@ static gint smtp_ehlo_recv(SMTPSession *session, const gchar *msg)
                const gchar *p = msg;
                p += 3;
                if (*p == '-' || *p == ' ') p++;
-               if (g_strncasecmp(p, "AUTH", 4) == 0) {
+               if (g_ascii_strncasecmp(p, "AUTH", 4) == 0) {
                        p += 5;
                        if (strcasestr(p, "LOGIN"))
                                session->avail_auth_type |= SMTPAUTH_LOGIN;
@@ -278,7 +289,7 @@ static gint smtp_ehlo_recv(SMTPSession *session, const gchar *msg)
                        if (strcasestr(p, "DIGEST-MD5"))
                                session->avail_auth_type |= SMTPAUTH_DIGEST_MD5;
                }
-               if (g_strncasecmp(p, "SIZE", 4) == 0) {
+               if (g_ascii_strncasecmp(p, "SIZE", 4) == 0) {
                        p += 5;
                        session->max_message_size = atoi(p);
                }
@@ -481,11 +492,14 @@ static gint smtp_session_recv_msg(Session *session, const gchar *msg)
 
        switch (smtp_session->state) {
        case SMTP_READY:
+               if (strstr(msg, "ESMTP"))
+                       smtp_session->is_esmtp = TRUE;
        case SMTP_CONNECTED:
 #if USE_OPENSSL
-               if (smtp_session->user || session->ssl_type != SSL_NONE)
+               if (smtp_session->user || session->ssl_type != SSL_NONE ||
+                   smtp_session->is_esmtp)
 #else
-               if (smtp_session->user)
+               if (smtp_session->user || smtp_session->is_esmtp)
 #endif
                        smtp_ehlo(smtp_session);
                else