39
39
const char *temp[10];
42
static const char *unfold_header(const char *str)
47
for (i = 0; str[i] != '\0'; i++) {
55
new_str = t_malloc(i + strlen(str+i) + 1);
56
memcpy(new_str, str, i);
57
for (j = i; str[i] != '\0'; i++) {
61
i_assert(str[i] == ' ' || str[i] == '\t');
63
new_str[j++] = str[i];
70
static const char *const *
71
unfold_multiline_headers(const char *const *headers)
73
const char **new_headers;
76
/* see if there are any multiline headers */
77
for (i = 0; headers[i] != NULL; i++) {
78
if (strchr(headers[i], '\n') != NULL)
81
if (headers[i] == NULL) {
87
for (; headers[i] != NULL; i++) ;
88
new_headers = t_new(const char *, i + 1);
89
for (i = 0; headers[i] != NULL; i++)
90
new_headers[i] = unfold_header(headers[i]);
42
94
/* gets the header "head" from msg. */
43
95
static int getheader(void *v, const char *phead, const char ***body)
45
97
sieve_msgdata_t *m = v;
98
const char *const *headers;
47
100
if (phead==NULL) return SIEVE_FAIL;
48
*body = (const char **)mail_get_headers(m->mail, phead);
101
headers = mail_get_headers(m->mail, phead);
103
headers = unfold_multiline_headers(headers);
104
*body = (const char **)headers;
346
402
static int autorespond(void *ac,
347
403
void *ic __attr_unused__,
349
void *mc __attr_unused__,
350
406
const char **errmsg __attr_unused__)
352
408
sieve_autorespond_context_t *arc = (sieve_autorespond_context_t *) ac;
353
409
script_data_t *sd = (script_data_t *) sc;
410
sieve_msgdata_t *md = mc;
356
412
/* ok, let's see if we've responded before */
357
ret = duplicate_check(arc->hash, arc->len, sd->username) ?
358
SIEVE_DONE : SIEVE_OK;
360
if (ret == SIEVE_OK) {
361
duplicate_mark(arc->hash, arc->len, sd->username,
362
ioloop_time + arc->days * (24 * 60 * 60));
413
if (duplicate_check(arc->hash, arc->len, sd->username)) {
414
i_info("msgid=%s: discarded duplicate vacation response to <%s>",
415
md->id == NULL ? "" : str_sanitize(md->id, 80),
416
str_sanitize(md->return_path, 80));
420
duplicate_mark(arc->hash, arc->len, sd->username,
421
ioloop_time + arc->days * (24 * 60 * 60));
368
426
static int send_response(void *ac,
409
467
if (smtp_client_close(smtp_client) == 0) {
410
468
duplicate_mark(outmsgid, strlen(outmsgid),
411
469
sdata->username, ioloop_time + DUPLICATE_DEFAULT_KEEP);
470
i_info("msgid=%s: sent vacation response to <%s>",
471
md->id == NULL ? "" : str_sanitize(md->id, 80),
472
str_sanitize(md->return_path, 80));
414
475
*errmsg = "Error sending mail";