# HG changeset patch # User Ben Schmidt # Date 1462851209 -36000 # Node ID 4bcd0168ddf9d226111ff43ea1dd6772968c890e # Parent 72c345b0aa91c46d67c812a8fe76b62fc24536fa Add smtphelo tunable (Andreas Schulze). diff -r 72c345b0aa91 -r 4bcd0168ddf9 ChangeLog --- a/ChangeLog Thu May 05 10:20:14 2016 +1000 +++ b/ChangeLog Tue May 10 13:33:29 2016 +1000 @@ -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 diff -r 72c345b0aa91 -r 4bcd0168ddf9 TUNABLES --- a/TUNABLES Thu May 05 10:20:14 2016 +1000 +++ b/TUNABLES Tue May 10 13:33:29 2016 +1000 @@ -254,3 +254,7 @@ 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. diff -r 72c345b0aa91 -r 4bcd0168ddf9 contrib/web/perl-admin/conf/tunables.pl --- a/contrib/web/perl-admin/conf/tunables.pl Thu May 05 10:20:14 2016 +1000 +++ b/contrib/web/perl-admin/conf/tunables.pl Tue May 10 13:33:29 2016 +1000 @@ -237,3 +237,7 @@ "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."); diff -r 72c345b0aa91 -r 4bcd0168ddf9 contrib/web/php-admin/conf/tunables.pl --- a/contrib/web/php-admin/conf/tunables.pl Thu May 05 10:20:14 2016 +1000 +++ b/contrib/web/php-admin/conf/tunables.pl Tue May 10 13:33:29 2016 +1000 @@ -237,3 +237,7 @@ "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."); diff -r 72c345b0aa91 -r 4bcd0168ddf9 include/mlmmj-send.h --- a/include/mlmmj-send.h Thu May 05 10:20:14 2016 +1000 +++ b/include/mlmmj-send.h Tue May 10 13:33:29 2016 +1000 @@ -45,7 +45,7 @@ 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 */ diff -r 72c345b0aa91 -r 4bcd0168ddf9 src/mlmmj-send.c --- a/src/mlmmj-send.c Thu May 05 10:20:14 2016 +1000 +++ b/src/mlmmj-send.c Tue May 10 13:33:29 2016 +1000 @@ -376,12 +376,11 @@ 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 @@ } 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 @@ */ } - 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 @@ } while (1); - myfree(myhostname); return retval; } @@ -820,7 +818,7 @@ 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 @@ 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 @@ } 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 @@ } 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 @@ 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 @@ } 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 @@ } 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 @@ } } 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 @@ } 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 @@ munmap(mailmap, st.st_size); close(mailfd); myfree(verp); + myfree(smtphelo); if(archive) { if(!ctrlarchive) {