]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
Send our hostname in HELO and change the mlmmj-send output from
authormmj <none@none>
Fri, 21 May 2004 08:46:00 +0000 (18:46 +1000)
committermmj <none@none>
Fri, 21 May 2004 08:46:00 +0000 (18:46 +1000)
 Connected: ok
 HELO: ok
 MAIL FROM: ok
 RCPT TO: ok
 DATA: ok 35x
 Mail queued: ok
 Closed connection

To:

 220 panther.mmj.dk ESMTP
 250 panther.mmj.dk
 250 Ok
 250 Ok
 354 End data with <CR><LF>.<CR><LF>
 250 Ok: queued as A8DA4F2FA4
 221 Bye

src/checkwait_smtpreply.c
src/mlmmj-send.c
src/strgen.c

index ad694fb9a5c7d92d2909fbf9505dcc5fe7caec22..7310775f98d0fb43b33f6a1f3be3a240cfa5bba1 100644 (file)
@@ -29,7 +29,7 @@ int checkwait_smtpreply(int sockfd, int replytype)
        } while(smtpreply[len-1] != '\n' && timer < LOOP_WAIT);
 
        smtpreply[len] = 0;
-#if MLMMJ_DEBUG
+#if 0
        printf("replytype = [%d], smtpreply = [%s]\n", replytype, smtpreply);
 #endif
        if(timer > LOOP_WAIT) {
@@ -37,47 +37,40 @@ int checkwait_smtpreply(int sockfd, int replytype)
                return -1;
        }
 
+       printf("%s", smtpreply);
+
        switch(replytype) {
        case MLMMJ_CONNECT:
                if(smtpreply[0] != '2' && smtpreply[1] != '2')
                        return MLMMJ_CONNECT;
-               printf("Connected: ok\n");
                break;
        case MLMMJ_HELO:
                if(smtpreply[0] != '2' && smtpreply[1] != '5')
                        return MLMMJ_HELO;
-               printf("HELO: ok\n");
                break;
        case MLMMJ_FROM:
                if(smtpreply[0] != '2' && smtpreply[1] != '5')
                        return MLMMJ_FROM;
-               printf("MAIL FROM: ok\n");
                break;
        case MLMMJ_RCPTTO:
                if(smtpreply[0] != '2' && smtpreply[1] != '5')
                        return MLMMJ_RCPTTO;
-               printf("RCPT TO: ok\n");
-
                break;
        case MLMMJ_DATA:
                if(smtpreply[0] != '3' && smtpreply[1] != '5')
                        return MLMMJ_DATA;
-               printf("DATA: ok 35x\n");
                break;
        case MLMMJ_DOT:
                if(smtpreply[0] != '2' && smtpreply[1] != '5')
                        return MLMMJ_DOT;
-               printf("Mail queued: ok\n");
                break;
        case MLMMJ_QUIT:
                if(smtpreply[0] != '2' && smtpreply[1] != '2')
                        return MLMMJ_QUIT;
-               printf("Closed connection\n");
                break;
        case MLMMJ_RSET:
                if(smtpreply[0] != '2' && smtpreply[1] != '5')
                        return MLMMJ_RSET;
-               printf("RSET: ok");
                break;
        default:
                break;
index 21fcc69de1fcdae4c67bccf417a6c85f11dadedd..8885eb8b7ea1e0626b3e523d4f19e078fd46343d 100644 (file)
@@ -161,6 +161,7 @@ int send_mail(int sockfd, const char *from, const char *to,
 int initsmtp(int *sockfd, const char *relayhost)
 {
        int retval = 0;
+       char *myhostname = hostnamestr();
        
        init_sockfd(sockfd, relayhost);
        
@@ -169,7 +170,8 @@ int initsmtp(int *sockfd, const char *relayhost)
                          "We continue and hope for the best\n");
                /* FIXME: Queue etc. */
        }       
-       write_helo(*sockfd, relayhost);
+       write_helo(*sockfd, myhostname);
+       free(myhostname);
        if((checkwait_smtpreply(*sockfd, MLMMJ_HELO)) != 0) {
                log_error(LOG_ARGS, "Error with HELO\n"
                          "We continue and hope for the best\n");
index d305bc163b51e476fcf262c128b4a507184952d6..db0c171f107dc22630a7a059b572f741b4af7215 100644 (file)
@@ -10,6 +10,8 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdarg.h>
+#include <unistd.h>
+#include <netdb.h>
 
 #include "strgen.h"
 #include "wrappers.h"
@@ -113,3 +115,14 @@ char *concatstr(int count, ...)
         return retstr;
 }
 
+char *hostnamestr()
+{
+        struct hostent *hostlookup;
+        char hostname[1024];
+
+        gethostname(hostname, sizeof(hostname) - 1);
+        hostlookup = gethostbyname(hostname);
+
+        return strdup(hostlookup->h_name);
+}
+