X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Fsmtp%2Fserv_smtpclient.c;h=6889b02f5f348ec1e9445641f763491bf17ac235;hb=e296d020094c0c326fd00c1a3f420f2f6aafd019;hp=38248046acc9a17bb3fa2cab7f506df983ddf492;hpb=47de9db6fce6a256640ead459207fb24a2ccb210;p=citadel.git diff --git a/citadel/modules/smtp/serv_smtpclient.c b/citadel/modules/smtp/serv_smtpclient.c index 38248046a..6889b02f5 100644 --- a/citadel/modules/smtp/serv_smtpclient.c +++ b/citadel/modules/smtp/serv_smtpclient.c @@ -79,7 +79,7 @@ void smtp_init_spoolout(void) { /* * Make sure it's set to be a "system room" so it doesn't show up - * in the nown rooms list for Aides. + * in the nown rooms list for administrators. */ if (CtdlGetRoomLock(&qrbuf, SMTP_SPOOLOUT_ROOM) == 0) { qrbuf.QRflags2 |= QR2_SYSTEM; @@ -238,6 +238,7 @@ int smtp_attempt_delivery(long msgid, char *recp, char *envelope_from) curl_easy_setopt(curl, CURLOPT_TIMEOUT, 20L); // Time out after 20 seconds curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); + // curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_error_buffer); strcpy(try_this_mx, "smtp://"); extract_token(&try_this_mx[7], mxes, i, '|', (sizeof try_this_mx - 7)); @@ -248,7 +249,6 @@ int smtp_attempt_delivery(long msgid, char *recp, char *envelope_from) strcpy(try_this_mx, &try_this_mx[7]); } - curl_easy_setopt(curl, CURLOPT_URL, try_this_mx); syslog(LOG_DEBUG, "smtpclient: trying %s", try_this_mx); // send the message @@ -262,8 +262,10 @@ int smtp_attempt_delivery(long msgid, char *recp, char *envelope_from) response_code = 421; } - curl_slist_free_all(recipients); - curl_easy_cleanup(curl); + curl_slist_free_all(recipients); + recipients = NULL; // this gets reused; avoid double-free + curl_easy_cleanup(curl); + curl = NULL; // this gets reused; avoid double-free } } @@ -287,11 +289,9 @@ void smtp_process_one_msg(long qmsgnum) long deletes[2]; int delete_this_queue = 0; - syslog(LOG_DEBUG, "smtpclient: smtp_process_one_msg(%ld)", qmsgnum); - msg = CtdlFetchMessage(qmsgnum, 1, 1); if (msg == NULL) { - syslog(LOG_WARNING, "smtpclient: queue message %ld does not exist", qmsgnum); + syslog(LOG_WARNING, "smtpclient: %ld does not exist", qmsgnum); return; } @@ -327,7 +327,7 @@ void smtp_process_one_msg(long qmsgnum) if (!strncasecmp(cfgline, HKEY("envelope_from|"))) envelope_from = strdup(&cfgline[14]); } - int should_try_now = 1; + int should_try_now = 0; if (attempted < submitted) { // If no attempts have been made yet, try now should_try_now = 1; } @@ -343,8 +343,7 @@ void smtp_process_one_msg(long qmsgnum) } if (should_try_now) { - syslog(LOG_DEBUG, "smtpclient: attempting delivery"); - + syslog(LOG_DEBUG, "smtpclient: %ld attempting delivery now", qmsgnum); StrBuf *NewInstr = NewStrBuf(); StrBufAppendPrintf(NewInstr, "Content-type: "SPOOLMIME"\n\n"); StrBufAppendPrintf(NewInstr, "msgid|%ld\n", msgid); @@ -414,15 +413,15 @@ void smtp_process_one_msg(long qmsgnum) } if (delete_this_queue) { - syslog(LOG_DEBUG, "smtpclient: deleting this queue entry"); + syslog(LOG_DEBUG, "smtpclient: %ld deleting", qmsgnum); deletes[0] = qmsgnum; deletes[1] = msgid; CtdlDeleteMessages(SMTP_SPOOLOUT_ROOM, deletes, 2, ""); FreeStrBuf(&NewInstr); // We have to free NewInstr here, no longer needed } else { - // replace the old qmsg with the new one - syslog(LOG_DEBUG, "smtpclient: rewriting this queue entry"); + // 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 CtdlSubmitMsg(msg, NULL, SMTP_SPOOLOUT_ROOM, 0); CM_Free(msg); @@ -430,13 +429,12 @@ void smtp_process_one_msg(long qmsgnum) } } else { - syslog(LOG_DEBUG, "smtpclient: retry time not reached"); + syslog(LOG_DEBUG, "smtpclient: %ld retry time not reached", qmsgnum); } if (bounceto != NULL) free(bounceto); if (envelope_from != NULL) free(envelope_from); free(instr); - } @@ -467,7 +465,7 @@ void smtp_do_queue(void) { int i = 0; /* - * This is a simple concurrency check to make sure only one pop3client + * This is a simple concurrency check to make sure only one smtpclient * run is done at a time. We could do this with a mutex, but since we * don't really require extremely fine granularity here, we'll do it * with a static variable instead.