From: mmj Date: Fri, 21 May 2004 08:46:00 +0000 (+1000) Subject: Send our hostname in HELO and change the mlmmj-send output from X-Git-Tag: RELEASE_1_0_0~230 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2b7f2fe17fc9ff65827df49f58f02f3981a23d9f;p=thirdparty%2Fmlmmj.git Send our hostname in HELO and change the mlmmj-send output from 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 . 250 Ok: queued as A8DA4F2FA4 221 Bye --- diff --git a/src/checkwait_smtpreply.c b/src/checkwait_smtpreply.c index ad694fb9..7310775f 100644 --- a/src/checkwait_smtpreply.c +++ b/src/checkwait_smtpreply.c @@ -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; diff --git a/src/mlmmj-send.c b/src/mlmmj-send.c index 21fcc69d..8885eb8b 100644 --- a/src/mlmmj-send.c +++ b/src/mlmmj-send.c @@ -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"); diff --git a/src/strgen.c b/src/strgen.c index d305bc16..db0c171f 100644 --- a/src/strgen.c +++ b/src/strgen.c @@ -10,6 +10,8 @@ #include #include #include +#include +#include #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); +} +