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)  

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