changeset 458:7c3190e7cff9

Tunable port to connect to
author mmj
date Wed, 09 Feb 2005 05:13:14 +1100
parents da6291416e50
children 42501eca3d2a
files TUNABLES include/init_sockfd.h include/mlmmj-send.h src/init_sockfd.c src/mlmmj-send.c
diffstat 5 files changed, 23 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/TUNABLES	Tue Feb 08 20:34:33 2005 +1100
+++ b/TUNABLES	Wed Feb 09 05:13:14 2005 +1100
@@ -132,3 +132,8 @@
    being denied due to the listaddress not being in To: or Cc: (see 'tocc'),
    when it was rejected due to an access rule (see 'access') or whether it's a
    subscribers only posting list (see 'subonlypost').
+
+ · smtpport			(normal)
+
+   In this file a port other than port 25 for connecting to the relayhost
+   can be specified.
--- a/include/init_sockfd.h	Tue Feb 08 20:34:33 2005 +1100
+++ b/include/init_sockfd.h	Wed Feb 09 05:13:14 2005 +1100
@@ -24,6 +24,6 @@
 #ifndef INIT_SOCKFD_H
 #define INIT_SOCKFD_H
 
-void init_sockfd(int *sockfd, const char *relayhost);
+void init_sockfd(int *sockfd, const char *relayhost, unsigned short port);
 
 #endif /* INIT_SOCKFD_H */
--- a/include/mlmmj-send.h	Tue Feb 08 20:34:33 2005 +1100
+++ b/include/mlmmj-send.h	Wed Feb 09 05:13:14 2005 +1100
@@ -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);
+int initsmtp(int *sockfd, const char *relayhost, unsigned short port);
 int endsmtp(int *sockfd);
 
 #endif /* MMJML_SEND_H */
--- a/src/init_sockfd.c	Tue Feb 08 20:34:33 2005 +1100
+++ b/src/init_sockfd.c	Wed Feb 09 05:13:14 2005 +1100
@@ -32,11 +32,10 @@
 #include "init_sockfd.h"
 #include "log_error.h"
 
-void init_sockfd(int *sockfd, const char *relayhost)
+void init_sockfd(int *sockfd, const char *relayhost, unsigned short port)
 {
 	int len;
 	struct sockaddr_in addr;
-	u_short port = 25;
 
 	if (getenv("MLMMJ_TESTING")) {
 		relayhost = "127.0.0.1";
--- a/src/mlmmj-send.c	Tue Feb 08 20:34:33 2005 +1100
+++ b/src/mlmmj-send.c	Wed Feb 09 05:13:14 2005 +1100
@@ -290,13 +290,13 @@
 	return 0;
 }
 
-int initsmtp(int *sockfd, const char *relayhost)
+int initsmtp(int *sockfd, const char *relayhost, unsigned short port)
 {
 	int retval = 0;
 	char *reply = NULL;
 	char *myhostname = hostnamestr();
 	
-	init_sockfd(sockfd, relayhost);
+	init_sockfd(sockfd, relayhost, port);
 	
 	if((reply = checkwait_smtpreply(*sockfd, MLMMJ_CONNECT)) != NULL) {
 		log_error(LOG_ARGS, "No proper greeting to our connect"
@@ -600,7 +600,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;
+	char strindex[32], *reply, *strport;
 	ssize_t memmailsize = 0;
 	DIR *subddir;
 	struct dirent *dp;
@@ -608,6 +608,7 @@
 	struct hostent *relayent;
 	uid_t uid;
 	struct strlist stl;
+	unsigned short smtpport = 25;
 
 	CHECKFULLPATH(argv[0]);
 	
@@ -863,11 +864,14 @@
 				strncpy(relay, RELAYHOST, sizeof(relay));
 		}
 	}
+	strport = ctrlvalue(listdir, "smtpport");
+	if(strport)
+		smtpport = (unsigned short)atol(strport);
 
 	switch(listctrl[0]) {
 	case '1': /* A single mail is to be sent */
 	case '6':
-		initsmtp(&sockfd, relay);
+		initsmtp(&sockfd, relay, smtpport);
 		sendres = send_mail(sockfd, bounceaddr, to_addr, replyto,
 				mailmap, st.st_size, listdir, NULL,
 				hdrs, hdrslen, body, bodylen);
@@ -910,7 +914,7 @@
 		}
 		break;
 	case '2': /* Moderators */
-		initsmtp(&sockfd, relay);
+		initsmtp(&sockfd, relay, smtpport);
 		if(send_mail_many_fd(sockfd, bounceaddr, NULL, mailmap,
 				     st.st_size, subfd, NULL, NULL, listdir,
 				     NULL, hdrs, hdrslen, body, bodylen))
@@ -919,7 +923,7 @@
 			endsmtp(&sockfd);
 		break;
 	case '3': /* resending earlier failed mails */
-		initsmtp(&sockfd, relay);
+		initsmtp(&sockfd, relay, smtpport);
 		if(send_mail_many_fd(sockfd, NULL, NULL, mailmap, st.st_size,
 				subfd, listaddr, mailfilename, listdir,
 				mlmmjbounce, hdrs, hdrslen, body, bodylen))
@@ -929,7 +933,7 @@
 		unlink(subfilename);
 		break;
 	case '4': /* send mails to owner */
-		initsmtp(&sockfd, relay);
+		initsmtp(&sockfd, relay, smtpport);
 		if(send_mail_many_fd(sockfd, bounceaddr, NULL, mailmap,
 				st.st_size, subfd, listaddr, mailfilename,
 				listdir, mlmmjbounce, hdrs, hdrslen, body,
@@ -939,7 +943,7 @@
 			endsmtp(&sockfd);
 		break;
 	case '5': /* bounceprobe - handle relayhost local users bouncing*/
-		initsmtp(&sockfd, relay);
+		initsmtp(&sockfd, relay, smtpport);
 		sendres = send_mail(sockfd, bounceaddr, to_addr, replyto,
 				mailmap, st.st_size, listdir, NULL,
 				hdrs, hdrslen, body, bodylen);
@@ -999,7 +1003,7 @@
 		}
 		
 		if(verp) {
-			initsmtp(&sockfd, relay);
+			initsmtp(&sockfd, relay, smtpport);
 			if(write_mail_from(sockfd, verpfrom, verp)) {
 				log_error(LOG_ARGS,
 						"Could not write MAIL FROM\n");
@@ -1034,7 +1038,7 @@
 				res = getaddrsfromfd(&stl, subfd,
 						maxverprecips);
 				if(stl.count == maxverprecips) {
-					initsmtp(&sockfd, relay);
+					initsmtp(&sockfd, relay, smtpport);
 					if(verp) {
 						sendres = send_mail_verp(
 								sockfd, &stl,
@@ -1072,7 +1076,7 @@
 
 		}
 		if(stl.count) {
-			initsmtp(&sockfd, relay);
+			initsmtp(&sockfd, relay, smtpport);
 			if(verp) {
 				sendres = send_mail_verp(sockfd, &stl, mailmap,
 						st.st_size, verpfrom, listdir,