SMTP-Client: fix target port handling for relay & fallback hosts
authorWilfried Goesgens <dothebart@citadel.org>
Mon, 11 Jun 2012 20:24:13 +0000 (22:24 +0200)
committerWilfried Goesgens <dothebart@citadel.org>
Mon, 11 Jun 2012 20:24:13 +0000 (22:24 +0200)
citadel/modules/smtp/serv_smtpeventclient.c
citadel/modules/smtp/serv_smtpqueue.c
citadel/modules/smtp/smtpqueue.h

index a411ef7d1ecf2575ef0bface76afe53da8ca20cc..c7de74fac3e9da7fffd65b10251b42c36a9411af 100644 (file)
@@ -91,7 +91,6 @@
 #include "smtp_clienthandlers.h"
 
 int SMTPClientDebugEnabled = 0;
-const unsigned short DefaultMXPort = 25;
 void DeleteSmtpOutMsg(void *v)
 {
        SmtpOutMsg *Msg = v;
@@ -322,6 +321,8 @@ eNextState get_one_mx_host_ip_done(AsyncIO *IO)
        SmtpOutMsg *Msg = IO->Data;
        struct hostent *hostent;
 
+       IO->ConnectMe = Msg->pCurrRelay;
+
        QueryCbDone(IO);
        EVS_syslog(LOG_DEBUG, "%s Time[%fs]\n",
                   __FUNCTION__,
@@ -339,7 +340,7 @@ eNextState get_one_mx_host_ip_done(AsyncIO *IO)
                        Msg->pCurrRelay->Addr.sin6_family =
                                hostent->h_addrtype;
                        Msg->pCurrRelay->Addr.sin6_port =
-                               htons(DefaultMXPort);
+                               htons(Msg->IO.ConnectMe->Port);
                }
                else {
                        struct sockaddr_in *addr;
@@ -357,7 +358,7 @@ eNextState get_one_mx_host_ip_done(AsyncIO *IO)
                               sizeof(uint32_t));
 
                        addr->sin_family = hostent->h_addrtype;
-                       addr->sin_port   = htons(DefaultMXPort);
+                       addr->sin_port   = htons(Msg->IO.ConnectMe->Port);
                }
                Msg->mx_host = Msg->pCurrRelay->Host;
                if (Msg->HostLookup.VParsedDNSReply != NULL) {
index b874d1268452870449d405922989cb31d4a4f1b8..589b13a482156ecdc9de2ba9e1a9fd1f15fe1490 100644 (file)
@@ -94,6 +94,7 @@ struct CitContext smtp_queue_CC;
 pthread_mutex_t ActiveQItemsLock;
 HashList *ActiveQItems  = NULL;
 HashList *QItemHandlers = NULL;
+const unsigned short DefaultMXPort = 25;
 int max_sessions_for_outbound_smtp = 500; /* how many sessions might be active till we stop adding more smtp jobs */
 int ndelay_count = 50; /* every n queued messages we will sleep... */
 int delay_msec = 5000; /* this many seconds. */
@@ -829,7 +830,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
                                !IsEmptyStr(Pos)))
                        {
                                StrBufExtract_NextToken(One, All, &Pos, '|');
-                               if (!ParseURL(Url, One, 25)) {
+                               if (!ParseURL(Url, One, DefaultMXPort)) {
                                        SMTPC_syslog(LOG_DEBUG,
                                                     "Failed to parse: %s\n",
                                                     ChrPtr(One));
@@ -857,7 +858,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
                                !IsEmptyStr(Pos)))
                        {
                                StrBufExtract_NextToken(One, All, &Pos, '|');
-                               if (!ParseURL(Url, One, 25)) {
+                               if (!ParseURL(Url, One, DefaultMXPort)) {
                                        SMTPC_syslog(LOG_DEBUG,
                                                     "Failed to parse: %s\n",
                                                     ChrPtr(One));
index c6cd97f5810c25a0914f9023a2d231b732a9b126..288e8b2e9b97bd5d0d5c3b54a2d7cb0a48061653 100644 (file)
@@ -22,6 +22,7 @@
 /*****************************************************************************/
 
 #define MaxAttempts 15
+extern const unsigned short DefaultMXPort;
 
 typedef struct _mailq_entry {
        StrBuf *Recipient;