From: "A. Schulze" <sca@andreasschulze.de>
To: mlmmj@mlmmj.org
Subject: [mlmmj] patch: set smtp helo name by TUNABLE
Date: Fri, 28 Nov 2014 20:50:40 +0000 [thread overview]
Message-ID: <20141128215040.Horde.ix21kWgKmZmBu6byTn_8Yg3@horde.andreasschulze.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 372 bytes --]
Hello,
attached a patch for mlmmj-1.2.18.1.
mlmmj submitting a message via smtp use the real hostname as helo
argument inside the smtp session.
That name is visible in the received header generated by the MTA.
I had to hide the real hostname running the list but use a defined
name when mlmmj submit messages.
The patch introduce a new tunable "smtphelo"
Andreas
[-- Attachment #2: smtp_helo_name.patch --]
[-- Type: text/x-diff, Size: 4659 bytes --]
Index: mlmmj-1.2.18.1/src/mlmmj-send.c
===================================================================
--- mlmmj-1.2.18.1.orig/src/mlmmj-send.c 2014-11-28 19:58:06.000000000 +0100
+++ mlmmj-1.2.18.1/src/mlmmj-send.c 2014-11-28 20:04:07.000000000 +0100
@@ -376,11 +376,10 @@
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;
char *reply = NULL;
- char *myhostname = hostnamestr();
init_sockfd(sockfd, relayhost, port);
@@ -394,8 +393,7 @@
retval = MLMMJ_CONNECT;
/* FIXME: Queue etc. */
}
- write_helo(*sockfd, myhostname);
- myfree(myhostname);
+ write_helo(*sockfd, heloname);
if((reply = checkwait_smtpreply(*sockfd, MLMMJ_HELO)) != NULL) {
log_error(LOG_ARGS, "Error with HELO. Reply: [%s]", reply);
/* FIXME: quit and tell admin to configure correctly */
@@ -728,7 +726,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;
@@ -1012,10 +1010,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)) {
@@ -1073,7 +1075,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,
@@ -1085,7 +1087,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,
@@ -1098,7 +1100,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,
@@ -1110,7 +1112,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)) {
@@ -1175,7 +1177,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,
@@ -1239,7 +1241,7 @@
}
}
if(stl.count == maxverprecips) {
- initsmtp(&sockfd, relay, smtpport);
+ initsmtp(&sockfd, relay, smtpport, smtphelo);
if(verp) {
sendres = send_mail_verp(
sockfd, &stl,
@@ -1283,7 +1285,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,
@@ -1324,6 +1326,7 @@
munmap(mailmap, st.st_size);
close(mailfd);
myfree(verp);
+ myfree(smtphelo);
if(archive) {
if(!ctrlarchive) {
Index: mlmmj-1.2.18.1/include/mlmmj-send.h
===================================================================
--- mlmmj-1.2.18.1.orig/include/mlmmj-send.h 2014-11-28 19:58:06.000000000 +0100
+++ mlmmj-1.2.18.1/include/mlmmj-send.h 2014-11-28 19:59:44.000000000 +0100
@@ -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 */
next reply other threads:[~2014-11-28 20:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-28 20:50 A. Schulze [this message]
2014-11-30 20:22 ` [mlmmj] patch: set smtp helo name by TUNABLE Ben Schmidt
2014-12-01 20:10 ` A. Schulze
2014-12-04 3:53 ` Ben Schmidt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141128215040.Horde.ix21kWgKmZmBu6byTn_8Yg3@horde.andreasschulze.de \
--to=sca@andreasschulze.de \
--cc=mlmmj@mlmmj.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).