From: Wilfried Goesgens Date: Mon, 11 Jun 2012 20:24:13 +0000 (+0200) Subject: SMTP-Client: fix target port handling for relay & fallback hosts X-Git-Tag: v8.12~18 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=8ffb37bf859b810c6f3c0895d1cd2edba32e54bf SMTP-Client: fix target port handling for relay & fallback hosts --- diff --git a/citadel/modules/smtp/serv_smtpeventclient.c b/citadel/modules/smtp/serv_smtpeventclient.c index a411ef7d1..c7de74fac 100644 --- a/citadel/modules/smtp/serv_smtpeventclient.c +++ b/citadel/modules/smtp/serv_smtpeventclient.c @@ -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) { diff --git a/citadel/modules/smtp/serv_smtpqueue.c b/citadel/modules/smtp/serv_smtpqueue.c index b874d1268..589b13a48 100644 --- a/citadel/modules/smtp/serv_smtpqueue.c +++ b/citadel/modules/smtp/serv_smtpqueue.c @@ -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)); diff --git a/citadel/modules/smtp/smtpqueue.h b/citadel/modules/smtp/smtpqueue.h index c6cd97f58..288e8b2e9 100644 --- a/citadel/modules/smtp/smtpqueue.h +++ b/citadel/modules/smtp/smtpqueue.h @@ -22,6 +22,7 @@ /*****************************************************************************/ #define MaxAttempts 15 +extern const unsigned short DefaultMXPort; typedef struct _mailq_entry { StrBuf *Recipient;