citadel
About: Citadel is an advanced messaging and collaboration system for groupware and BBS applications (preferred OS: Linux).
  Fossies Dox: citadel.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Loading...
Searching...
No Matches
serv_smtpclient.c
Go to the documentation of this file.
1// Transmit outbound SMTP mail to the big wide world of the Internet
2//
3// This is the new, exciting, clever version that makes libcurl do all the work :)
4//
5// Copyright (c) 1997-2022 by the citadel.org team
6//
7// This program is open source software; you can redistribute it and/or
8// modify it under the terms of the GNU General Public License as published
9// by the Free Software Foundation; either version 3 of the License, or
10// (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16
17#include <stdlib.h>
18#include <unistd.h>
19#include <stdio.h>
20#include <time.h>
21#include <ctype.h>
22#include <string.h>
23#include <errno.h>
24#include <sys/types.h>
25#include <sys/stat.h>
26#include <libcitadel.h>
27#include <curl/curl.h>
28#include "../../sysconfig.h"
29#include "../../citadel.h"
30#include "../../server.h"
31#include "../../citserver.h"
32#include "../../support.h"
33#include "../../config.h"
34#include "../../ctdl_module.h"
35#include "../../clientsocket.h"
36#include "../../msgbase.h"
37#include "../../domain.h"
38#include "../../internet_addressing.h"
39#include "../../citadel_dirs.h"
40#include "../smtp/smtp_util.h"
41
42struct smtpmsgsrc { // Data passed in and out of libcurl for message upload
43 StrBuf *TheMessage;
46};
47
48static int doing_smtpclient = 0;
49long *smtpq = NULL; // array of msgnums containing queue instructions
50int smtpq_count = 0; // number of queue messages in smtpq
51int smtpq_alloc = 0; // current allocation size for smtpq
52
53
54// Initialize the SMTP outbound queue
56 struct ctdlroom qrbuf;
57
58 // Create the room. This will silently fail if the room already
59 // exists, and that's perfectly ok, because we want it to exist.
60 CtdlCreateRoom(SMTP_SPOOLOUT_ROOM, 3, "", 0, 1, 0, VIEW_QUEUE);
61
62 // Make sure it's set to be a "system room" so it doesn't show up
63 // in the <K>nown rooms list for administrators.
67 }
68}
69
70
71// For internet mail, generate delivery instructions.
72// Yes, this is recursive. Deal with it. Infinite recursion does
73// not happen because the delivery instructions message does not
74// contain a recipient.
75int smtp_aftersave(struct CtdlMessage *msg, struct recptypes *recps) {
76 if ((recps != NULL) && (recps->num_internet > 0)) {
77 struct CtdlMessage *imsg = NULL;
78 char recipient[SIZ];
79 StrBuf *SpoolMsg = NewStrBuf();
80 long nTokens;
81 int i;
82
83 syslog(LOG_DEBUG, "smtpclient: generating delivery instructions");
84
85 StrBufPrintf(SpoolMsg,
86 "Content-type: " SPOOLMIME "\n"
87 "\n"
88 "msgid|%s\n"
89 "submitted|%ld\n" "bounceto|%s\n", msg->cm_fields[eVltMsgNum], (long) time(NULL), recps->bounce_to);
90
91 if (recps->envelope_from != NULL) {
92 StrBufAppendBufPlain(SpoolMsg, HKEY("envelope_from|"), 0);
93 StrBufAppendBufPlain(SpoolMsg, recps->envelope_from, -1, 0);
94 StrBufAppendBufPlain(SpoolMsg, HKEY("\n"), 0);
95 }
96 if (recps->sending_room != NULL) {
97 StrBufAppendBufPlain(SpoolMsg, HKEY("source_room|"), 0);
98 StrBufAppendBufPlain(SpoolMsg, recps->sending_room, -1, 0);
99 StrBufAppendBufPlain(SpoolMsg, HKEY("\n"), 0);
100 }
101
102 nTokens = num_tokens(recps->recp_internet, '|');
103 for (i = 0; i < nTokens; i++) {
104 long len;
105 len = extract_token(recipient, recps->recp_internet, i, '|', sizeof recipient);
106 if (len > 0) {
107 StrBufAppendBufPlain(SpoolMsg, HKEY("remote|"), 0);
108 StrBufAppendBufPlain(SpoolMsg, recipient, len, 0);
109 StrBufAppendBufPlain(SpoolMsg, HKEY("|0||\n"), 0);
110 }
111 }
112
113 imsg = malloc(sizeof(struct CtdlMessage));
114 memset(imsg, 0, sizeof(struct CtdlMessage));
116 imsg->cm_anon_type = MES_NORMAL;
118 CM_SetField(imsg, eMsgSubject, HKEY("QMSG"));
119 CM_SetField(imsg, eAuthor, HKEY("Citadel"));
120 CM_SetField(imsg, eJournal, HKEY("do not journal"));
121 CM_SetAsFieldSB(imsg, eMesageText, &SpoolMsg);
123 CM_Free(imsg);
124 }
125 return 0;
126}
127
128
129// Callback for smtp_attempt_delivery() to supply libcurl with upload data.
130static size_t upload_source(void *ptr, size_t size, size_t nmemb, void *userp) {
131 struct smtpmsgsrc *s = (struct smtpmsgsrc *) userp;
132 int sendbytes = 0;
133 const char *send_this = NULL;
134
135 sendbytes = (size * nmemb);
136
137 if (s->bytes_sent >= s->bytes_total) {
138 return (0); // no data remaining; we are done
139 }
140
141 if (sendbytes > (s->bytes_total - s->bytes_sent)) {
142 sendbytes = s->bytes_total - s->bytes_sent; // can't send more than we have
143 }
144
145 send_this = ChrPtr(s->TheMessage);
146 send_this += s->bytes_sent; // start where we last left off
147
148 memcpy(ptr, send_this, sendbytes);
149 s->bytes_sent += sendbytes;
150 return(sendbytes); // return the number of bytes _actually_ copied
151}
152
153
154// The libcurl API doesn't provide a way to capture the actual SMTP result message returned
155// by the remote server. This is an ugly way to extract it, by capturing debug data from
156// the library and filtering on the lines we want.
157int ctdl_libcurl_smtp_debug_callback(CURL *handle, curl_infotype type, char *data, size_t size, void *userptr) {
158 if (type != CURLINFO_HEADER_IN)
159 return 0;
160 if (!userptr)
161 return 0;
162 char *debugbuf = (char *) userptr;
163
164 int len = strlen(debugbuf);
165 if (len + size > SIZ)
166 return 0;
167
168 memcpy(&debugbuf[len], data, size);
169 debugbuf[len + size] = 0;
170 return 0;
171}
172
173
174// Go through the debug output of an SMTP transaction, and boil it down to just the final success or error response message.
175void trim_response(long response_code, char *response) {
176 if ((response_code < 100) || (response_code > 999) || (IsEmptyStr(response))) {
177 return;
178 }
179
180 char *t = malloc(strlen(response));
181 if (!t) {
182 return;
183 }
184 t[0] = 0;
185
186 char *p;
187 for (p = response; *p != 0; ++p) {
188 if ( (*p != '\n') && (!isprint(*p)) ) { // expunge any nonprintables except for newlines
189 *p = ' ';
190 }
191 }
192
193 char response_code_str[4];
194 snprintf(response_code_str, sizeof response_code_str, "%ld", response_code);
195 char *respstart = strstr(response, response_code_str);
196 if (respstart == NULL) { // If we have a response code but no response text,
197 strcpy(response, smtpstatus(response_code)); // use one of our canned messages.
198 return;
199 }
200 strcpy(response, respstart);
201
202 p = strstr(response, "\n");
203 if (p != NULL) {
204 *p = 0;
205 }
206}
207
208
209// Attempt a delivery to one recipient.
210// Returns a three-digit SMTP status code.
211int smtp_attempt_delivery(long msgid, char *recp, char *envelope_from, char *source_room, char *response) {
212 struct smtpmsgsrc s;
213 char *fromaddr = NULL;
214 CURL *curl;
215 CURLcode res = CURLE_OK;
216 struct curl_slist *recipients = NULL;
217 long response_code = 421;
218 int num_mx = 0;
219 char mxes[SIZ];
220 char user[1024];
221 char node[1024];
222 char name[1024];
223 char try_this_mx[256];
224 char smtp_url[512];
225 int i;
226
227 syslog(LOG_DEBUG, "smtpclient: smtp_attempt_delivery(%ld, %s)", msgid, recp);
228
229 process_rfc822_addr(recp, user, node, name); // split recipient address into username, hostname, displayname
230 num_mx = getmx(mxes, node);
231 if (num_mx < 1) {
232 return (421);
233 }
234
235 CC->redirect_buffer = NewStrBufPlain(NULL, SIZ);
236 if (!IsEmptyStr(source_room)) {
237 // If we have a source room, it's probably a mailing list message; generate an unsubscribe header
238 char esc_room[ROOMNAMELEN*2];
239 char esc_email[1024];
240 urlesc(esc_room, sizeof esc_room, source_room);
241 urlesc(esc_email, sizeof esc_email, recp);
242 cprintf("List-Unsubscribe: <http://%s/listsub?cmd=unsubscribe&room=%s&email=%s>\r\n",
243 CtdlGetConfigStr("c_fqdn"),
244 esc_room,
245 esc_email
246 );
247 }
248 CtdlOutputMsg(msgid, MT_RFC822, HEADERS_ALL, 0, 1, NULL, 0, NULL, &fromaddr, NULL);
249 s.TheMessage = CC->redirect_buffer;
250 s.bytes_total = StrLength(CC->redirect_buffer);
251 s.bytes_sent = 0;
252 CC->redirect_buffer = NULL;
253 response_code = 421;
254 // keep trying MXes until one works or we run out
255 for (i = 0; ((i < num_mx) && ((response_code / 100) == 4)); ++i) {
256 response_code = 421; // default 421 makes non-protocol errors transient
257 s.bytes_sent = 0; // rewind our buffer in case we try multiple MXes
258
259 curl = curl_easy_init();
260 if (curl) {
261 response[0] = 0;
262
263 if (!IsEmptyStr(envelope_from)) {
264 curl_easy_setopt(curl, CURLOPT_MAIL_FROM, envelope_from);
265 }
266 else {
267 curl_easy_setopt(curl, CURLOPT_MAIL_FROM, fromaddr);
268 }
269
270 recipients = curl_slist_append(recipients, recp);
271 curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);
272 curl_easy_setopt(curl, CURLOPT_READFUNCTION, upload_source);
273 curl_easy_setopt(curl, CURLOPT_READDATA, &s);
274 curl_easy_setopt(curl, CURLOPT_UPLOAD, 1); // tell libcurl we are uploading
275 curl_easy_setopt(curl, CURLOPT_TIMEOUT, 20L); // Time out after 20 seconds
276 if (CtdlGetConfigInt("c_smtpclient_disable_starttls") == 0) {
277 curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_TRY); // Attempt STARTTLS if offered
278 }
279 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
280 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
281 curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, ctdl_libcurl_smtp_debug_callback);
282 curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *) response);
283 curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
284
285 // Construct an SMTP URL in the form of:
286 // smtp[s]://target_host/source_host
287 // This looks weird but libcurl uses that last part to set our name for EHLO or HELO.
288 // We check for "smtp://" and "smtps://" because the admin may have put those prefixes in a smart-host entry.
289 // If there is no prefix we add "smtp://"
290 extract_token(try_this_mx, mxes, i, '|', (sizeof try_this_mx - 7));
291 snprintf(smtp_url, sizeof smtp_url,
292 "%s%s/%s",
293 (((!strncasecmp(try_this_mx, HKEY("smtp://")))
294 || (!strncasecmp(try_this_mx, HKEY("smtps://")))) ? "" : "smtp://"),
295 try_this_mx, CtdlGetConfigStr("c_fqdn")
296 );
297 curl_easy_setopt(curl, CURLOPT_URL, smtp_url);
298 syslog(LOG_DEBUG, "smtpclient: trying MX %d of %d <%s>", i+1, num_mx, smtp_url); // send the message
299 res = curl_easy_perform(curl);
300 curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
301 syslog(LOG_DEBUG,
302 "smtpclient: libcurl returned %d (%s) , SMTP response %ld",
303 res, curl_easy_strerror(res), response_code
304 );
305
306 if ((res != CURLE_OK) && (response_code == 0)) { // check for errors
307 response_code = 421;
308 }
309
310 curl_slist_free_all(recipients);
311 recipients = NULL; // this gets reused; avoid double-free
312 curl_easy_cleanup(curl);
313 curl = NULL; // this gets reused; avoid double-free
314
315 // Trim the error message buffer down to just the actual message
316 trim_response(response_code, response);
317 }
318 }
319
320 FreeStrBuf(&s.TheMessage);
321 if (fromaddr) {
322 free(fromaddr);
323 }
324 return ((int) response_code);
325}
326
327
328// Process one outbound message.
329void smtp_process_one_msg(long qmsgnum) {
330 struct CtdlMessage *msg = NULL;
331 char *instr = NULL;
332 int i;
333 int num_success = 0;
334 int num_fail = 0;
335 int num_delayed = 0;
336 long deletes[2];
337 int delete_this_queue = 0;
338 char server_response[SIZ];
339
340 msg = CtdlFetchMessage(qmsgnum, 1);
341 if (msg == NULL) {
342 syslog(LOG_WARNING, "smtpclient: %ld does not exist", qmsgnum);
343 return;
344 }
345
346 instr = msg->cm_fields[eMesageText];
347 msg->cm_fields[eMesageText] = NULL;
348 CM_Free(msg);
349
350 // if the queue message has any CRLF's convert them to LF's
351 char *crlf = NULL;
352 while (crlf = strstr(instr, "\r\n"), crlf != NULL) {
353 strcpy(crlf, crlf + 1);
354 }
355
356 // Strip out the headers and we are now left with just the instructions.
357 char *soi = strstr(instr, "\n\n");
358 if (soi) {
359 strcpy(instr, soi + 2);
360 }
361
362 long msgid = 0;
363 time_t submitted = time(NULL);
364 time_t attempted = 0;
365 char *bounceto = NULL;
366 char *envelope_from = NULL;
367 char *source_room = NULL;
368
369 char cfgline[SIZ];
370 for (i = 0; i < num_tokens(instr, '\n'); ++i) {
371 extract_token(cfgline, instr, i, '\n', sizeof cfgline);
372 if (!strncasecmp(cfgline, HKEY("msgid|")))
373 msgid = atol(&cfgline[6]);
374 if (!strncasecmp(cfgline, HKEY("submitted|")))
375 submitted = atol(&cfgline[10]);
376 if (!strncasecmp(cfgline, HKEY("attempted|")))
377 attempted = atol(&cfgline[10]);
378 if (!strncasecmp(cfgline, HKEY("bounceto|")))
379 bounceto = strdup(&cfgline[9]);
380 if (!strncasecmp(cfgline, HKEY("envelope_from|")))
381 envelope_from = strdup(&cfgline[14]);
382 if (!strncasecmp(cfgline, HKEY("source_room|")))
383 source_room = strdup(&cfgline[12]);
384 }
385
386 int should_try_now = 0;
387 if (attempted < submitted) { // If no attempts have been made yet, try now
388 should_try_now = 1;
389 }
390 else if ((attempted - submitted) <= 14400) {
391 if ((time(NULL) - attempted) > 1800) { // First four hours, retry every 30 minutes
392 should_try_now = 1;
393 }
394 }
395 else {
396 if ((time(NULL) - attempted) > 14400) { // After that, retry once every 4 hours
397 should_try_now = 1;
398 }
399 }
400
401 if (should_try_now) {
402 syslog(LOG_DEBUG, "smtpclient: attempting delivery of message <%ld> now", qmsgnum);
403 if (source_room) {
404 syslog(LOG_DEBUG, "smtpclient: this message originated in <%s>", source_room);
405 }
406 StrBuf *NewInstr = NewStrBuf();
407 StrBufAppendPrintf(NewInstr, "Content-type: " SPOOLMIME "\n\n");
408 StrBufAppendPrintf(NewInstr, "msgid|%ld\n", msgid);
409 StrBufAppendPrintf(NewInstr, "submitted|%ld\n", submitted);
410 if (bounceto) {
411 StrBufAppendPrintf(NewInstr, "bounceto|%s\n", bounceto);
412 }
413 if (envelope_from) {
414 StrBufAppendPrintf(NewInstr, "envelope_from|%s\n", envelope_from);
415 }
416 for (i = 0; i < num_tokens(instr, '\n'); ++i) {
417 extract_token(cfgline, instr, i, '\n', sizeof cfgline);
418 if (!strncasecmp(cfgline, HKEY("remote|"))) {
419 char recp[SIZ];
420 int previous_result = extract_int(cfgline, 2);
421 if ((previous_result == 0)
422 || (previous_result == 4)) {
423 int new_result = 421;
424 extract_token(recp, cfgline, 1, '|', sizeof recp);
425 new_result = smtp_attempt_delivery(msgid, recp, envelope_from, source_room, server_response);
426 syslog(LOG_DEBUG, "smtpclient: recp: <%s> , result: %d (%s)", recp, new_result, server_response);
427 if ((new_result / 100) == 2) {
428 ++num_success;
429 }
430 else {
431 if ((new_result / 100) == 5) {
432 ++num_fail;
433 }
434 else {
435 ++num_delayed;
436 }
437 StrBufAppendPrintf
438 (NewInstr,
439 "remote|%s|%ld|%ld (%s)\n",
440 recp, (new_result / 100), new_result, server_response);
441 }
442 }
443 }
444 }
445
446 StrBufAppendPrintf(NewInstr, "attempted|%ld\n", time(NULL));
447
448 // All deliveries have now been attempted. Now determine the disposition of this queue entry.
449
450 time_t age = time(NULL) - submitted;
451 syslog(LOG_DEBUG,
452 "smtpclient: submission age: %ldd%ldh%ldm%lds",
453 (age / 86400), ((age % 86400) / 3600), ((age % 3600) / 60), (age % 60));
454 syslog(LOG_DEBUG, "smtpclient: num_success=%d , num_fail=%d , num_delayed=%d", num_success, num_fail, num_delayed);
455
456 // If there are permanent fails on this attempt, deliver a bounce to the user.
457 // The 5XX fails will be recorded in the rewritten queue, but they will be removed before the next attempt.
458 if (num_fail > 0) {
459 smtp_do_bounce(ChrPtr(NewInstr), SDB_BOUNCE_FATALS);
460 }
461 // If all deliveries have either succeeded or failed, we are finished with this queue entry.
462 if (num_delayed == 0) {
463 delete_this_queue = 1;
464 }
465 // If it's been more than five days, give up and tell the sender that delivery failed
466 else if ((time(NULL) - submitted) > SMTP_DELIVER_FAIL) {
467 smtp_do_bounce(ChrPtr(NewInstr), SDB_BOUNCE_ALL);
468 delete_this_queue = 1;
469 }
470 // If it's been more than four hours but less than five days, warn the sender that delivery is delayed
471 else if (((attempted - submitted) < SMTP_DELIVER_WARN)
472 && ((time(NULL) - submitted) >= SMTP_DELIVER_WARN)) {
473 smtp_do_bounce(ChrPtr(NewInstr), SDB_WARN);
474 }
475
476 if (delete_this_queue) {
477 syslog(LOG_DEBUG, "smtpclient: %ld deleting", qmsgnum);
478 deletes[0] = qmsgnum;
479 deletes[1] = msgid;
480 CtdlDeleteMessages(SMTP_SPOOLOUT_ROOM, deletes, 2, "");
481 FreeStrBuf(&NewInstr); // We have to free NewInstr here, no longer needed
482 }
483 else {
484 // replace the old queue entry with the new one
485 syslog(LOG_DEBUG, "smtpclient: %ld rewriting", qmsgnum);
486 msg = convert_internet_message_buf(&NewInstr); // This function will free NewInstr for us
488 CM_Free(msg);
489 CtdlDeleteMessages(SMTP_SPOOLOUT_ROOM, &qmsgnum, 1, "");
490 }
491 }
492 else {
493 syslog(LOG_DEBUG, "smtpclient: %ld retry time not reached", qmsgnum);
494 }
495
496 if (bounceto != NULL) {
497 free(bounceto);
498 }
499 if (envelope_from != NULL) {
500 free(envelope_from);
501 }
502 if (source_room != NULL) {
503 free(source_room);
504 }
505 free(instr);
506}
507
508
509// Callback for smtp_do_queue()
510void smtp_add_msg(long msgnum, void *userdata) {
511
512 if (smtpq == NULL) {
513 smtpq_count = 0;
514 smtpq_alloc = 100;
515 smtpq = malloc(smtpq_alloc * sizeof(long));
516 }
517
518 if (smtpq_alloc >= smtpq_count) {
519 smtpq_alloc += 100;
520 smtpq = realloc(smtpq, (smtpq_alloc * sizeof(long)));
521 }
522
523 smtpq[smtpq_count++] = msgnum;
524}
525
526
527// Run through the queue sending out messages.
528void smtp_do_queue(void) {
529 int i = 0;
530
531 // This is a simple concurrency check to make sure only one smtpclient
532 // run is done at a time. We could do this with a mutex, but since we
533 // don't really require extremely fine granularity here, we'll do it
534 // with a static variable instead.
535 if (doing_smtpclient) {
536 return;
537 }
539
540 syslog(LOG_DEBUG, "smtpclient: start queue run");
541
542 if (CtdlGetRoom(&CC->room, SMTP_SPOOLOUT_ROOM) != 0) {
543 syslog(LOG_WARNING, "Cannot find room <%s>", SMTP_SPOOLOUT_ROOM);
545 return;
546 }
547 // Put the queue in memory so we can close the db cursor
548 CtdlForEachMessage(MSGS_ALL, 0L, NULL, SPOOLMIME, NULL, smtp_add_msg, NULL);
549
550 // We are ready to run through the queue now.
551 for (i = 0; i < smtpq_count; ++i) {
553 }
554
555 smtpq_count = 0; // don't free it, we will use this memory on the next run
557 syslog(LOG_DEBUG, "smtpclient: end queue run");
558}
559
560
561// Initialization function, called from modules_init.c
563 if (!threading) {
567 }
568
569 // return our module id for the log
570 return "smtpclient";
571}
#define ROOMNAMELEN
Definition: citadel.h:51
#define MES_NORMAL
Definition: citadel.h:118
char * CtdlGetConfigStr(char *key)
Definition: config.c:363
int CtdlGetConfigInt(char *key)
Definition: config.c:390
#define CC
Definition: context.h:140
int CtdlGetRoom(struct ctdlroom *qrbuf, const char *room_name)
Definition: room_ops.c:309
void CtdlRegisterSessionHook(void(*fcn_ptr)(void), int EventType, int Priority)
void CtdlRegisterMessageHook(int(*handler)(struct CtdlMessage *, struct recptypes *), int EventType)
int threading
Definition: modules_init.c:24
#define PRIO_AGGR
Definition: ctdl_module.h:76
int CtdlGetRoomLock(struct ctdlroom *qrbuf, const char *room_name)
Definition: room_ops.c:352
unsigned CtdlCreateRoom(char *new_room_name, int new_room_type, char *new_room_pass, int new_room_floor, int really_create, int avoid_access, int new_room_view)
Definition: room_ops.c:1035
void CtdlPutRoomLock(struct ctdlroom *qrbuf)
Definition: room_ops.c:400
int getmx(char *mxbuf, char *dest)
Definition: domain.c:89
struct CtdlMessage * convert_internet_message_buf(StrBuf **rfc822)
void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name)
#define QR2_SYSTEM
Definition: ipcdef.h:55
void CM_Free(struct CtdlMessage *msg)
Definition: msgbase.c:305
int CtdlOutputMsg(long msg_num, int mode, int headers_only, int do_proto, int crlf, char *section, int flags, char **Author, char **Address, char **MessageID)
Definition: msgbase.c:1470
int CtdlForEachMessage(int mode, long ref, char *search_string, char *content_type, struct CtdlMessage *compare, ForEachMsgCallback CallBack, void *userdata)
Definition: msgbase.c:621
struct CtdlMessage * CtdlFetchMessage(long msgnum, int with_body)
Definition: msgbase.c:1128
int CtdlDeleteMessages(const char *room_name, long *dmsgnums, int num_dmsgnums, char *content_type)
Definition: msgbase.c:3229
long CtdlSubmitMsg(struct CtdlMessage *msg, struct recptypes *recps, const char *force)
Definition: msgbase.c:2588
void CM_SetField(struct CtdlMessage *Msg, eMsgField which, const char *buf, long length)
Definition: msgbase.c:137
void CM_SetAsFieldSB(struct CtdlMessage *Msg, eMsgField which, StrBuf **buf)
Definition: msgbase.c:253
#define HEADERS_ALL
Definition: msgbase.h:39
@ MSGS_ALL
Definition: msgbase.h:6
void * malloc(unsigned)
void free(void *)
struct ctdlroom qrbuf
Definition: serv_migrate.c:497
void smtp_process_one_msg(long qmsgnum)
void smtp_init_spoolout(void)
int smtp_aftersave(struct CtdlMessage *msg, struct recptypes *recps)
static int doing_smtpclient
void trim_response(long response_code, char *response)
void smtp_add_msg(long msgnum, void *userdata)
long * smtpq
int smtpq_alloc
char * ctdl_module_init_smtpclient(void)
int smtp_attempt_delivery(long msgid, char *recp, char *envelope_from, char *source_room, char *response)
static size_t upload_source(void *ptr, size_t size, size_t nmemb, void *userp)
void smtp_do_queue(void)
int smtpq_count
int ctdl_libcurl_smtp_debug_callback(CURL *handle, curl_infotype type, char *data, size_t size, void *userptr)
#define CTDLMESSAGE_MAGIC
Definition: server.h:42
@ eMesageText
Definition: server.h:315
@ eVltMsgNum
Definition: server.h:327
@ eAuthor
Definition: server.h:307
@ eMsgSubject
Definition: server.h:320
@ eJournal
Definition: server.h:312
#define EVT_AFTERSAVE
Definition: server.h:232
#define FMT_RFC822
Definition: server.h:178
#define EVT_TIMER
Definition: server.h:224
@ MT_RFC822
Definition: server.h:167
char * smtpstatus(int code)
Definition: smtp_util.c:305
void smtp_do_bounce(const char *instr, int is_final)
Definition: smtp_util.c:72
@ SDB_BOUNCE_FATALS
Definition: smtp_util.h:37
@ SDB_BOUNCE_ALL
Definition: smtp_util.h:38
@ SDB_WARN
Definition: smtp_util.h:39
int cm_magic
Definition: server.h:34
char cm_anon_type
Definition: server.h:35
char * cm_fields[256]
Definition: server.h:37
char cm_format_type
Definition: server.h:36
unsigned QRflags2
Definition: citadel.h:107
int num_internet
Definition: server.h:50
char * bounce_to
Definition: server.h:59
char * sending_room
Definition: server.h:61
char * envelope_from
Definition: server.h:60
char * recp_internet
Definition: server.h:55
StrBuf * TheMessage
#define SMTP_SPOOLOUT_ROOM
Definition: sysconfig.h:73
#define SMTP_DELIVER_WARN
Definition: sysconfig.h:49
#define SMTP_DELIVER_FAIL
Definition: sysconfig.h:50
#define SIZ
Definition: sysconfig.h:33
void cprintf(const char *format,...)
Definition: sysdep.c:369