]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
Add smtphelo tunable (Andreas Schulze).
authorBen Schmidt <none@none>
Tue, 10 May 2016 03:33:29 +0000 (13:33 +1000)
committerBen Schmidt <none@none>
Tue, 10 May 2016 03:33:29 +0000 (13:33 +1000)
ChangeLog
TUNABLES
contrib/web/perl-admin/conf/tunables.pl
contrib/web/php-admin/conf/tunables.pl
include/mlmmj-send.h
src/mlmmj-send.c

index 390fdab35699dda2994ca197d084ff042c2ce34e..d8fc412b5787f11f77f60541e180c6134cd9c3e5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+ o Add smtphelo tunable (Andreas Schulze)
  o Implement modonlypost
 1.2.19.0
  o Add README.footers and footer-related resources
index a9b05cf8ef189b7f26f1591a07b076dbb9f85224..6346836dc14dff426678664fce2f5a677f459b6a 100644 (file)
--- a/TUNABLES
+++ b/TUNABLES
@@ -254,3 +254,7 @@ entire content is used as value, it's marked "text".
    from the distribution list for that post so people don't receive copies
    of their own posts.
 
+ ยท smtphelo                   (normal)
+
+   When this file is present, it contains the hostname to send in the SMTP
+   EHLO or HELO command. Otherwise the machine hostname is used.
index 77cf2fe14d9d803158e4ee6ce9550464066b2aaf..c57297d713a2cbc5d42b7a9efba996ee3108a5e8 100644 (file)
@@ -237,3 +237,7 @@ mlmmj_boolean("notmetoo",
                          "from the distribution list for that post so people don't receive copies ".
                          "of their own posts.");
 
+mlmmj_string("smtphelo",
+                         "SMTP Helo Name",
+                         "When this file is present, it contains the hostname to send in the SMTP ".
+                         "EHLO or HELO command. Otherwise the machine hostname is used.");
index dcb0ba388a35cbaf9a71c0c6c9d9e63aebc14142..4374b8f5b5ffe884f3c666c6a519dfe00fc54f07 100644 (file)
@@ -237,3 +237,7 @@ mlmmj_boolean("notmetoo",
                          "from the distribution list for that post so people don't receive copies ".
                          "of their own posts.");
 
+mlmmj_string("smtphelo",
+                         "SMTP Helo Name",
+                         "When this file is present, it contains the hostname to send in the SMTP ".
+                         "EHLO or HELO command. Otherwise the machine hostname is used.");
index 2d9144220f6651066cc874333fa5cc6f1ab87ea9..923ad318d7cc355491de838b1a21e4c12d3e5672 100644 (file)
@@ -45,7 +45,7 @@ int send_mail_verp(int sockfd, struct strlist *addrs, char *mailmap,
                   size_t mailsize, const char *from, const char *listdir,
                   const char *hdrs, size_t hdrslen, const char *body,
                   size_t bodylen, const char *extra);
-int initsmtp(int *sockfd, const char *relayhost, unsigned short port);
+int initsmtp(int *sockfd, const char *relayhost, unsigned short port, const char *heloname);
 int endsmtp(int *sockfd);
 
 #endif /* MMJML_SEND_H */
index 17e8efed33f281c96e7257222775ee8be47a60fe..db0761086c5b2300571acec9b7738e57e51d5715 100644 (file)
@@ -376,12 +376,11 @@ int send_mail(int sockfd, const char *from, const char *to,
        return 0;
 }
 
-int initsmtp(int *sockfd, const char *relayhost, unsigned short port)
+int initsmtp(int *sockfd, const char *relayhost, unsigned short port, const char *heloname)
 {
        int retval = 0;
        int try_ehlo = 1;
        char *reply = NULL;
-       char *myhostname = hostnamestr();
 
        do {
                init_sockfd(sockfd, relayhost, port);
@@ -401,7 +400,7 @@ int initsmtp(int *sockfd, const char *relayhost, unsigned short port)
                }
 
                if (try_ehlo) {
-                       write_ehlo(*sockfd, myhostname);
+                       write_ehlo(*sockfd, heloname);
                        if((reply = checkwait_smtpreply(*sockfd, MLMMJ_EHLO))
                                        == NULL) {
                                /* EHLO successful don't try more */
@@ -468,7 +467,7 @@ int initsmtp(int *sockfd, const char *relayhost, unsigned short port)
                         */
                }
 
-               write_helo(*sockfd, myhostname);
+               write_helo(*sockfd, heloname);
                if((reply = checkwait_smtpreply(*sockfd, MLMMJ_HELO))
                                == NULL) {
                        /* EHLO successful don't try more */
@@ -494,7 +493,6 @@ int initsmtp(int *sockfd, const char *relayhost, unsigned short port)
 
        } while (1);
 
-       myfree(myhostname);
        return retval;
 }
 
@@ -820,7 +818,7 @@ int main(int argc, char **argv)
        char *mlmmjbounce = NULL, *bindir, *mailmap, *probefile, *a;
        char *body = NULL, *hdrs = NULL, *memmailsizestr = NULL, *verp = NULL;
        char relay[16], *listname, *listfqdn, *verpfrom, *maxverprecipsstr;
-       char strindex[32], *reply, *strport, *requeuefilename;
+       char strindex[32], *reply, *strport, *smtphelo, *requeuefilename;
        ssize_t memmailsize = 0;
        DIR *subddir;
        struct dirent *dp;
@@ -1102,10 +1100,14 @@ int main(int argc, char **argv)
        if(strport)
                smtpport = (unsigned short)atol(strport);
 
+       if ((smtphelo = ctrlvalue(listdir, "smtphelo")) == NULL) {
+               smtphelo = hostnamestr();
+       }
+
        switch(listctrl[0]) {
        case '1': /* A single mail is to be sent */
        case '6':
-               initsmtp(&sockfd, relay, smtpport);
+               initsmtp(&sockfd, relay, smtpport, smtphelo);
                if(send_mail(sockfd, bounceaddr, to_addr, replyto,
                                mailmap, st.st_size, listdir, NULL,
                                hdrs, hdrslen, body, bodylen)) {
@@ -1163,7 +1165,7 @@ int main(int argc, char **argv)
                }
                break;
        case '2': /* Moderators */
-               initsmtp(&sockfd, relay, smtpport);
+               initsmtp(&sockfd, relay, smtpport, smtphelo);
                if(send_mail_many_fd(sockfd, bounceaddr, NULL, mailmap,
                                     st.st_size, subfd, NULL, NULL, NULL,
                                     listdir, NULL, hdrs, hdrslen,
@@ -1175,7 +1177,7 @@ int main(int argc, char **argv)
                }
                break;
        case '3': /* resending earlier failed mails */
-               initsmtp(&sockfd, relay, smtpport);
+               initsmtp(&sockfd, relay, smtpport, smtphelo);
                if(send_mail_many_fd(sockfd, NULL, NULL, mailmap, st.st_size,
                                subfd, listaddr, listdelim, mailfilename,
                                listdir, mlmmjbounce, hdrs, hdrslen,
@@ -1188,7 +1190,7 @@ int main(int argc, char **argv)
                unlink(subfilename);
                break;
        case '4': /* send mails to owner */
-               initsmtp(&sockfd, relay, smtpport);
+               initsmtp(&sockfd, relay, smtpport, smtphelo);
                if(send_mail_many_fd(sockfd, bounceaddr, NULL, mailmap,
                                st.st_size, subfd, listaddr, listdelim,
                                mailfilename, listdir, mlmmjbounce,
@@ -1200,7 +1202,7 @@ int main(int argc, char **argv)
                }
                break;
        case '5': /* bounceprobe - handle relayhost local users bouncing*/
-               initsmtp(&sockfd, relay, smtpport);
+               initsmtp(&sockfd, relay, smtpport, smtphelo);
                if(send_mail(sockfd, bounceaddr, to_addr, replyto,
                                mailmap, st.st_size, listdir, NULL,
                                hdrs, hdrslen, body, bodylen)) {
@@ -1265,7 +1267,7 @@ int main(int argc, char **argv)
                }
                
                if(verp) {
-                       initsmtp(&sockfd, relay, smtpport);
+                       initsmtp(&sockfd, relay, smtpport, smtphelo);
                        if(sockfd > -1) {
                            if(write_mail_from(sockfd, verpfrom, verp)) {
                                log_error(LOG_ARGS,
@@ -1329,7 +1331,7 @@ int main(int argc, char **argv)
                                        }
                                }
                                if(stl.count == maxverprecips) {
-                                       initsmtp(&sockfd, relay, smtpport);
+                                       initsmtp(&sockfd, relay, smtpport, smtphelo);
                                        if(verp) {
                                                sendres = send_mail_verp(
                                                                sockfd, &stl,
@@ -1373,7 +1375,7 @@ int main(int argc, char **argv)
 
                }
                if(stl.count) {
-                       initsmtp(&sockfd, relay, smtpport);
+                       initsmtp(&sockfd, relay, smtpport, smtphelo);
                        if(verp) {
                                sendres = send_mail_verp(sockfd, &stl, mailmap,
                                                st.st_size, verpfrom, listdir,
@@ -1414,6 +1416,7 @@ int main(int argc, char **argv)
        munmap(mailmap, st.st_size);
        close(mailfd);
        myfree(verp);
+       myfree(smtphelo);
 
        if(archive) {
                if(!ctrlarchive) {