X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Fsmtp%2Fserv_smtpclient.c;h=bdc2fb75452f400dbae96f6f8118645aae40bf73;hb=5165e905c8c869b92876738b0436c9e784abce3a;hp=c266a259bdc730e2e9d3c186263c8a0e75eee7ee;hpb=cb3eac8fb6440223370d3608c445438000d2b908;p=citadel.git diff --git a/citadel/modules/smtp/serv_smtpclient.c b/citadel/modules/smtp/serv_smtpclient.c index c266a259b..bdc2fb754 100644 --- a/citadel/modules/smtp/serv_smtpclient.c +++ b/citadel/modules/smtp/serv_smtpclient.c @@ -300,7 +300,7 @@ int smtp_attempt_delivery(long msgid, char *recp, char *envelope_from, char *res try_this_mx, CtdlGetConfigStr("c_fqdn") ); curl_easy_setopt(curl, CURLOPT_URL, smtp_url); - syslog(LOG_DEBUG, "smtpclient: trying %s", smtp_url); // send the message + syslog(LOG_DEBUG, "smtpclient: trying MX %d of %d <%s>", i+1, num_mx, smtp_url); // send the message res = curl_easy_perform(curl); curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code); syslog(LOG_DEBUG, @@ -322,8 +322,9 @@ int smtp_attempt_delivery(long msgid, char *recp, char *envelope_from, char *res } FreeStrBuf(&s.TheMessage); - if (fromaddr) + if (fromaddr) { free(fromaddr); + } return ((int) response_code); } @@ -388,27 +389,30 @@ void smtp_process_one_msg(long qmsgnum) { int should_try_now = 0; if (attempted < submitted) { // If no attempts have been made yet, try now should_try_now = 1; - } else if ((attempted - submitted) <= 14400) { + } + else if ((attempted - submitted) <= 14400) { if ((time(NULL) - attempted) > 1800) { // First four hours, retry every 30 minutes should_try_now = 1; } - } else { + } + else { if ((time(NULL) - attempted) > 14400) { // After that, retry once every 4 hours should_try_now = 1; } } if (should_try_now) { - syslog(LOG_DEBUG, "smtpclient: %ld attempting delivery now", qmsgnum); + syslog(LOG_DEBUG, "smtpclient: attempting delivery of message <%ld> now", qmsgnum); StrBuf *NewInstr = NewStrBuf(); StrBufAppendPrintf(NewInstr, "Content-type: " SPOOLMIME "\n\n"); StrBufAppendPrintf(NewInstr, "msgid|%ld\n", msgid); StrBufAppendPrintf(NewInstr, "submitted|%ld\n", submitted); - if (bounceto) + if (bounceto) { StrBufAppendPrintf(NewInstr, "bounceto|%s\n", bounceto); - if (envelope_from) + } + if (envelope_from) { StrBufAppendPrintf(NewInstr, "envelope_from|%s\n", envelope_from); - + } for (i = 0; i < num_tokens(instr, '\n'); ++i) { extract_token(cfgline, instr, i, '\n', sizeof cfgline); if (!strncasecmp(cfgline, HKEY("remote|"))) { @@ -423,10 +427,12 @@ void smtp_process_one_msg(long qmsgnum) { "smtpclient: recp: <%s> , result: %d (%s)", recp, new_result, server_response); if ((new_result / 100) == 2) { ++num_success; - } else { + } + else { if ((new_result / 100) == 5) { ++num_fail; - } else { + } + else { ++num_delayed; } StrBufAppendPrintf @@ -477,7 +483,8 @@ void smtp_process_one_msg(long qmsgnum) { deletes[1] = msgid; CtdlDeleteMessages(SMTP_SPOOLOUT_ROOM, deletes, 2, ""); FreeStrBuf(&NewInstr); // We have to free NewInstr here, no longer needed - } else { + } + else { // replace the old queue entry with the new one syslog(LOG_DEBUG, "smtpclient: %ld rewriting", qmsgnum); msg = convert_internet_message_buf(&NewInstr); // This function will free NewInstr for us @@ -485,14 +492,17 @@ void smtp_process_one_msg(long qmsgnum) { CM_Free(msg); CtdlDeleteMessages(SMTP_SPOOLOUT_ROOM, &qmsgnum, 1, ""); } - } else { + } + else { syslog(LOG_DEBUG, "smtpclient: %ld retry time not reached", qmsgnum); } - if (bounceto != NULL) + if (bounceto != NULL) { free(bounceto); - if (envelope_from != NULL) + } + if (envelope_from != NULL) { free(envelope_from); + } free(instr); } @@ -529,8 +539,9 @@ void smtp_do_queue(void) { * don't really require extremely fine granularity here, we'll do it * with a static variable instead. */ - if (doing_smtpclient) + if (doing_smtpclient) { return; + } doing_smtpclient = 1; syslog(LOG_DEBUG, "smtpclient: start queue run"); @@ -561,7 +572,7 @@ CTDL_MODULE_INIT(smtpclient) { if (!threading) { CtdlRegisterMessageHook(smtp_aftersave, EVT_AFTERSAVE); - CtdlRegisterSessionHook(smtp_do_queue, EVT_TIMER, PRIO_AGGR + 50); + CtdlRegisterSessionHook(smtp_do_queue, EVT_TIMER, PRIO_AGGR + 51); smtp_init_spoolout(); }