~ubuntu-branches/ubuntu/utopic/dovecot/utopic-proposed

« back to all changes in this revision

Viewing changes to pigeonhole/src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-01-08 09:35:49 UTC
  • mfrom: (4.1.35 sid)
  • Revision ID: package-import@ubuntu.com-20140108093549-i72o93pux8p0dlaf
Tags: 1:2.2.9-1ubuntu1
* Merge from Debian unstable, remaining changes:
  + Add mail-stack-delivery package:
    - Update d/rules
    - d/control: convert existing dovecot-postfix package to a dummy
      package and add new mail-stack-delivery package.
    - Update maintainer scripts.
    - Rename d/dovecot-postfix.* to debian/mail-stack-delivery.*
    - d/mail-stack-delivery.preinst: Move previously installed backups and
      config files to a new package namespace.
    - d/mail-stack-delivery.prerm: Added to handle downgrades.
  + Use Snakeoil SSL certificates by default:
    - d/control: Depend on ssl-cert.
    - d/dovecot-core.postinst: Relax grep for SSL_* a bit.
  + Add autopkgtest to debian/tests/*.
  + Add ufw integration:
    - d/dovecot-core.ufw.profile: new ufw profile.
    - d/rules: install profile in dovecot-core.
    - d/control: dovecot-core - suggest ufw.
  + d/dovecot-core.dirs: Added usr/share/doc/dovecot-core
  + Add apport hook:
    - d/rules, d/source_dovecot.py
  + Add upstart job:
    - d/rules, d/dovecot-core.dovecot.upstart, d/control,
      d/dovecot-core.dirs, dovecot-imapd.{postrm, postinst, prerm},
      d/dovecot-pop3d.{postinst, postrm, prerm}.
      d/mail-stack-deliver.postinst: Convert init script to upstart.
  + Use the autotools-dev dh addon to update config.guess/config.sub for
    arm64.
* Dropped changes, included in Debian:
  - Update Dovecot name to reflect distribution in login greeting.
  - Update Drac plugin for >= 2.0.0 support.
* d/control: Drop dovecot-postfix package as its no longer required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2002-2012 Pigeonhole authors, see the included COPYING file 
 
1
/* Copyright (c) 2002-2013 Pigeonhole authors, see the included COPYING file
2
2
 */
3
 
 
 
3
 
4
4
/* Notify method mailto
5
5
 * --------------------
6
6
 *
8
8
 * Specification: RFC 5436
9
9
 * Implementation: full
10
10
 * Status: testing
11
 
 * 
 
11
 *
12
12
 */
13
 
 
 
13
 
14
14
/* FIXME: URI syntax conforms to something somewhere in between RFC 2368 and
15
15
 *   draft-duerst-mailto-bis-05.txt. Should fully migrate to new specification
16
16
 *   when it matures. This requires modifications to the address parser (no
17
17
 *   whitespace allowed within the address itself) and UTF-8 support will be
18
18
 *   required in the URL.
19
19
 */
20
 
 
 
20
 
21
21
#include "lib.h"
22
22
#include "array.h"
23
23
#include "str.h"
24
24
#include "ioloop.h"
25
25
#include "str-sanitize.h"
 
26
#include "ostream.h"
26
27
#include "message-date.h"
27
28
#include "mail-storage.h"
28
29
 
40
41
/*
41
42
 * Configuration
42
43
 */
43
 
 
 
44
 
44
45
#define NTFY_MAILTO_MAX_RECIPIENTS  8
45
46
#define NTFY_MAILTO_MAX_HEADERS     16
46
47
#define NTFY_MAILTO_MAX_SUBJECT     256
47
48
 
48
 
/* 
 
49
/*
49
50
 * Mailto notification method
50
51
 */
51
 
 
 
52
 
52
53
static bool ntfy_mailto_compile_check_uri
53
54
        (const struct sieve_enotify_env *nenv, const char *uri, const char *uri_body);
54
55
static bool ntfy_mailto_compile_check_from
55
56
        (const struct sieve_enotify_env *nenv, string_t *from);
56
57
 
57
58
static const char *ntfy_mailto_runtime_get_notify_capability
58
 
        (const struct sieve_enotify_env *nenv, const char *uri, const char *uri_body, 
 
59
        (const struct sieve_enotify_env *nenv, const char *uri, const char *uri_body,
59
60
                const char *capability);
60
61
static bool ntfy_mailto_runtime_check_uri
61
62
        (const struct sieve_enotify_env *nenv, const char *uri, const char *uri_body);
62
63
static bool ntfy_mailto_runtime_check_operands
63
 
        (const struct sieve_enotify_env *nenv, const char *uri,const char *uri_body, 
64
 
                string_t *message, string_t *from, pool_t context_pool, 
 
64
        (const struct sieve_enotify_env *nenv, const char *uri,const char *uri_body,
 
65
                string_t *message, string_t *from, pool_t context_pool,
65
66
                void **method_context);
66
67
 
67
68
static int ntfy_mailto_action_check_duplicates
68
 
        (const struct sieve_enotify_env *nenv, 
 
69
        (const struct sieve_enotify_env *nenv,
69
70
                const struct sieve_enotify_action *nact,
70
71
                const struct sieve_enotify_action *nact_other);
71
72
 
72
73
static void ntfy_mailto_action_print
73
 
        (const struct sieve_enotify_print_env *penv, 
74
 
                const struct sieve_enotify_action *nact);       
 
74
        (const struct sieve_enotify_print_env *penv,
 
75
                const struct sieve_enotify_action *nact);
75
76
 
76
77
static bool ntfy_mailto_action_execute
77
 
        (const struct sieve_enotify_exec_env *nenv, 
 
78
        (const struct sieve_enotify_exec_env *nenv,
78
79
                const struct sieve_enotify_action *nact);
79
80
 
80
81
const struct sieve_enotify_method_def mailto_notify = {
81
82
        "mailto",
82
 
        NULL, NULL, 
 
83
        NULL, NULL,
83
84
        ntfy_mailto_compile_check_uri,
84
85
        NULL,
85
86
        ntfy_mailto_compile_check_from,
94
95
};
95
96
 
96
97
/*
97
 
 * Reserved and unique headers 
 
98
 * Reserved and unique headers
98
99
 */
99
 
 
 
100
 
100
101
static const char *_reserved_headers[] = {
101
102
        "auto-submitted",
102
103
        "received",
138
139
static bool ntfy_mailto_compile_check_uri
139
140
(const struct sieve_enotify_env *nenv, const char *uri ATTR_UNUSED,
140
141
        const char *uri_body)
141
 
{       
 
142
{
142
143
        return uri_mailto_validate
143
144
                (uri_body, _reserved_headers, _unique_headers,
144
145
                        NTFY_MAILTO_MAX_RECIPIENTS, NTFY_MAILTO_MAX_HEADERS, nenv->ehandler);
167
168
/*
168
169
 * Runtime
169
170
 */
170
 
 
 
171
 
171
172
static const char *ntfy_mailto_runtime_get_notify_capability
172
 
(const struct sieve_enotify_env *nenv ATTR_UNUSED, const char *uri ATTR_UNUSED, 
 
173
(const struct sieve_enotify_env *nenv ATTR_UNUSED, const char *uri ATTR_UNUSED,
173
174
        const char *uri_body, const char *capability)
174
175
{
175
176
        if ( !uri_mailto_validate(uri_body, _reserved_headers, _unique_headers,
176
177
                        NTFY_MAILTO_MAX_RECIPIENTS, NTFY_MAILTO_MAX_HEADERS, NULL) ) {
177
178
                return NULL;
178
179
        }
179
 
        
180
 
        if ( strcasecmp(capability, "online") == 0 ) 
 
180
 
 
181
        if ( strcasecmp(capability, "online") == 0 )
181
182
                return "maybe";
182
 
        
 
183
 
183
184
        return NULL;
184
185
}
185
186
 
191
192
                (uri_body, _reserved_headers, _unique_headers,
192
193
                        NTFY_MAILTO_MAX_RECIPIENTS, NTFY_MAILTO_MAX_HEADERS, NULL);
193
194
}
194
 
 
 
195
 
195
196
static bool ntfy_mailto_runtime_check_operands
196
197
(const struct sieve_enotify_env *nenv, const char *uri ATTR_UNUSED,
197
 
        const char *uri_body, string_t *message ATTR_UNUSED, string_t *from, 
 
198
        const char *uri_body, string_t *message ATTR_UNUSED, string_t *from,
198
199
        pool_t context_pool, void **method_context)
199
200
{
200
201
        struct ntfy_mailto_context *mtctx;
214
215
                                        "specified :from address '%s' is invalid for "
215
216
                                        "the mailto method: %s",
216
217
                                        str_sanitize(str_c(from), 128), error);
217
 
                        } else 
 
218
                        } else
218
219
                                mtctx->from_normalized = p_strdup(context_pool, normalized);
219
220
                } T_END;
220
221
 
222
223
        }
223
224
 
224
225
        if ( (parsed_uri=uri_mailto_parse
225
 
                (uri_body, context_pool, _reserved_headers, 
 
226
                (uri_body, context_pool, _reserved_headers,
226
227
                        _unique_headers, NTFY_MAILTO_MAX_RECIPIENTS, NTFY_MAILTO_MAX_HEADERS,
227
228
                        nenv->ehandler)) == NULL ) {
228
229
                return FALSE;
230
231
 
231
232
        mtctx->uri = parsed_uri;
232
233
        *method_context = (void *) mtctx;
233
 
        return TRUE;    
 
234
        return TRUE;
234
235
}
235
236
 
236
237
/*
238
239
 */
239
240
 
240
241
static int ntfy_mailto_action_check_duplicates
241
 
(const struct sieve_enotify_env *nenv ATTR_UNUSED, 
242
 
        const struct sieve_enotify_action *nact, 
 
242
(const struct sieve_enotify_env *nenv ATTR_UNUSED,
 
243
        const struct sieve_enotify_action *nact,
243
244
        const struct sieve_enotify_action *nact_other)
244
245
{
245
 
        struct ntfy_mailto_context *mtctx = 
 
246
        struct ntfy_mailto_context *mtctx =
246
247
                (struct ntfy_mailto_context *) nact->method_context;
247
 
        struct ntfy_mailto_context *mtctx_other = 
 
248
        struct ntfy_mailto_context *mtctx_other =
248
249
                (struct ntfy_mailto_context *) nact_other->method_context;
249
250
        const struct uri_mailto_recipient *new_rcpts, *old_rcpts;
250
251
        unsigned int new_count, old_count, i, j;
257
258
                for ( j = 0; j < old_count; j++ ) {
258
259
                        if ( sieve_address_compare
259
260
                                (new_rcpts[i].normalized, old_rcpts[j].normalized, TRUE) == 0 )
260
 
                                break;                          
 
261
                                break;
261
262
                }
262
263
 
263
264
                if ( j == old_count ) {
270
271
                                i -= del_len;
271
272
                                new_rcpts = array_get(&mtctx->uri->recipients, &new_count);
272
273
                        }
273
 
                        del_len = 0;            
 
274
                        del_len = 0;
274
275
                } else {
275
276
                        /* Mark deletion */
276
277
                        if ( del_len == 0 )
281
282
 
282
283
        /* Perform pending deletion */
283
284
        if ( del_len > 0 ) {
284
 
                array_delete(&mtctx->uri->recipients, del_start, del_len);                      
 
285
                array_delete(&mtctx->uri->recipients, del_start, del_len);
285
286
        }
286
287
 
287
288
        return ( array_count(&mtctx->uri->recipients) > 0 ? 0 : 1 );
290
291
/*
291
292
 * Action printing
292
293
 */
293
 
 
 
294
 
294
295
static void ntfy_mailto_action_print
295
 
(const struct sieve_enotify_print_env *penv, 
 
296
(const struct sieve_enotify_print_env *penv,
296
297
        const struct sieve_enotify_action *nact)
297
298
{
298
299
        unsigned int count, i;
299
300
        const struct uri_mailto_recipient *recipients;
300
301
        const struct uri_mailto_header_field *headers;
301
 
        struct ntfy_mailto_context *mtctx = 
 
302
        struct ntfy_mailto_context *mtctx =
302
303
                (struct ntfy_mailto_context *) nact->method_context;
303
 
        
 
304
 
304
305
        /* Print main method parameters */
305
306
 
306
307
        sieve_enotify_method_printf
336
337
        }
337
338
 
338
339
        /* Print accepted headers for notification message */
339
 
        
 
340
 
340
341
        headers = array_get(&mtctx->uri->headers, &count);
341
342
        if ( count > 0 ) {
342
 
                sieve_enotify_method_printf(penv,   "    => headers      :\n" );        
 
343
                sieve_enotify_method_printf(penv,   "    => headers      :\n" );
343
344
                for ( i = 0; i < count; i++ ) {
344
 
                        sieve_enotify_method_printf(penv,   "       + %s: %s\n", 
 
345
                        sieve_enotify_method_printf(penv,   "       + %s: %s\n",
345
346
                                headers[i].name, headers[i].body);
346
347
                }
347
348
        }
348
349
 
349
350
        /* Print body for notification message */
350
 
        
 
351
 
351
352
        if ( mtctx->uri->body != NULL )
352
353
                sieve_enotify_method_printf
353
354
                        (penv, "    => body         : \n--\n%s\n--\n", mtctx->uri->body);
369
370
                if ((*s & 0x80) != 0)
370
371
                        return TRUE;
371
372
        }
372
 
        
 
373
 
373
374
        return FALSE;
374
375
}
375
376
 
376
377
static bool ntfy_mailto_send
377
 
(const struct sieve_enotify_exec_env *nenv, 
 
378
(const struct sieve_enotify_exec_env *nenv,
378
379
        const struct sieve_enotify_action *nact, const char *recipient)
379
 
 
380
{
380
381
        const struct sieve_message_data *msgdata = nenv->msgdata;
381
382
        const struct sieve_script_env *senv = nenv->scriptenv;
382
 
        struct ntfy_mailto_context *mtctx = 
383
 
                (struct ntfy_mailto_context *) nact->method_context;    
384
 
        const char *from = NULL, *from_smtp = NULL; 
 
383
        struct ntfy_mailto_context *mtctx =
 
384
                (struct ntfy_mailto_context *) nact->method_context;
 
385
        const char *from = NULL, *from_smtp = NULL;
385
386
        const char *subject = mtctx->uri->subject;
386
387
        const char *body = mtctx->uri->body;
387
388
        string_t *to, *cc;
388
389
        const struct uri_mailto_recipient *recipients;
 
390
        const struct uri_mailto_header_field *headers;
389
391
        void *smtp_handle;
390
 
        unsigned int count, i;
391
 
        FILE *f;
 
392
        struct ostream *output;
 
393
        string_t *msg;
 
394
        unsigned int count, i, hcount, h;
392
395
        const char *outmsgid;
393
396
 
394
397
        /* Get recipients */
395
398
        recipients = array_get(&mtctx->uri->recipients, &count);
396
399
        if ( count == 0  ) {
397
 
                sieve_enotify_warning(nenv, 
 
400
                sieve_enotify_warning(nenv,
398
401
                        "notify mailto uri specifies no recipients; action has no effect");
399
402
                return TRUE;
400
403
        }
401
404
 
402
405
        /* Just to be sure */
403
406
        if ( !sieve_smtp_available(senv) ) {
404
 
                sieve_enotify_global_warning(nenv, 
 
407
                sieve_enotify_global_warning(nenv,
405
408
                        "notify mailto method has no means to send mail");
406
409
                return TRUE;
407
410
        }
408
 
        
 
411
 
409
412
        /* Determine message from address */
410
413
        if ( nact->from == NULL ) {
411
414
                from = t_strdup_printf("Postmaster <%s>", senv->postmaster_address);
421
424
                        from_smtp = mtctx->from_normalized;
422
425
                }
423
426
        }
424
 
        
 
427
 
425
428
        /* Determine subject */
426
429
        if ( nact->message != NULL ) {
427
430
                /* FIXME: handle UTF-8 */
428
431
                subject = str_sanitize(nact->message, NTFY_MAILTO_MAX_SUBJECT);
429
432
        } else if ( subject == NULL ) {
430
433
                const char *const *hsubject;
431
 
                
 
434
 
432
435
                /* Fetch subject from original message */
433
436
                if ( mail_get_headers_utf8
434
437
                        (msgdata->mail, "subject", &hsubject) >= 0 )
435
 
                        subject = str_sanitize(t_strdup_printf("Notification: %s", hsubject[0]), 
 
438
                        subject = str_sanitize(t_strdup_printf("Notification: %s", hsubject[0]),
436
439
                                NTFY_MAILTO_MAX_SUBJECT);
437
440
                else
438
441
                        subject = "Notification: (no subject)";
461
464
                }
462
465
        }
463
466
 
 
467
        msg = t_str_new(512);
 
468
        outmsgid = sieve_message_get_new_id(nenv->svinst);
 
469
 
 
470
        rfc2822_header_write(msg, "X-Sieve", SIEVE_IMPLEMENTATION);
 
471
        rfc2822_header_write(msg, "Message-ID", outmsgid);
 
472
        rfc2822_header_write(msg, "Date", message_date_create(ioloop_time));
 
473
        rfc2822_header_utf8_printf(msg, "Subject", "%s", subject);
 
474
 
 
475
        rfc2822_header_utf8_printf(msg, "From", "%s", from);
 
476
 
 
477
        if ( to != NULL )
 
478
                rfc2822_header_utf8_printf(msg, "To", "%s", str_c(to));
 
479
 
 
480
        if ( cc != NULL )
 
481
                rfc2822_header_utf8_printf(msg, "Cc", "%s", str_c(cc));
 
482
 
 
483
        rfc2822_header_printf(msg, "Auto-Submitted",
 
484
                "auto-notified; owner-email=\"%s\"", recipient);
 
485
        rfc2822_header_write(msg, "Precedence", "bulk");
 
486
 
 
487
        /* Set importance */
 
488
        switch ( nact->importance ) {
 
489
        case 1:
 
490
                rfc2822_header_write(msg, "X-Priority", "1 (Highest)");
 
491
                rfc2822_header_write(msg, "Importance", "High");
 
492
                break;
 
493
        case 3:
 
494
                rfc2822_header_write(msg, "X-Priority", "5 (Lowest)");
 
495
                rfc2822_header_write(msg, "Importance", "Low");
 
496
                break;
 
497
        case 2:
 
498
        default:
 
499
                rfc2822_header_write(msg, "X-Priority", "3 (Normal)");
 
500
                rfc2822_header_write(msg, "Importance", "Normal");
 
501
                break;
 
502
        }
 
503
 
 
504
        /* Add custom headers */
 
505
 
 
506
        headers = array_get(&mtctx->uri->headers, &hcount);
 
507
        for ( h = 0; h < hcount; h++ ) {
 
508
                const char *name = rfc2822_header_field_name_sanitize(headers[h].name);
 
509
 
 
510
                rfc2822_header_write(msg, name, headers[h].body);
 
511
        }
 
512
 
 
513
        /* Generate message body */
 
514
 
 
515
        rfc2822_header_write(msg, "MIME-Version", "1.0");
 
516
        if ( body != NULL ) {
 
517
                if (_contains_8bit(body)) {
 
518
                        rfc2822_header_write
 
519
                                (msg, "Content-Type", "text/plain; charset=utf-8");
 
520
                        rfc2822_header_write(msg, "Content-Transfer-Encoding", "8bit");
 
521
                } else {
 
522
                        rfc2822_header_write
 
523
                                (msg, "Content-Type", "text/plain; charset=us-ascii");
 
524
                        rfc2822_header_write(msg, "Content-Transfer-Encoding", "7bit");
 
525
                }
 
526
                str_printfa(msg, "\r\n%s\r\n", body);
 
527
 
 
528
        } else {
 
529
                rfc2822_header_write
 
530
                        (msg, "Content-Type", "text/plain; charset=US-ASCII");
 
531
                rfc2822_header_write(msg, "Content-Transfer-Encoding", "7bit");
 
532
 
 
533
                str_append(msg, "\r\nNotification of new message.\r\n");
 
534
        }
 
535
 
464
536
        /* Send message to all recipients */
465
537
        for ( i = 0; i < count; i++ ) {
466
 
                const struct uri_mailto_header_field *headers;
467
 
                unsigned int h, hcount;
468
 
 
469
538
                smtp_handle = sieve_smtp_open
470
 
                        (senv, recipients[i].normalized, from_smtp, &f);
471
 
                outmsgid = sieve_message_get_new_id(nenv->svinst);
472
 
        
473
 
                rfc2822_header_field_write(f, "X-Sieve", SIEVE_IMPLEMENTATION);
474
 
                rfc2822_header_field_write(f, "Message-ID", outmsgid);
475
 
                rfc2822_header_field_write(f, "Date", message_date_create(ioloop_time));
476
 
                rfc2822_header_field_utf8_printf(f, "Subject", "%s", subject);
477
 
 
478
 
                rfc2822_header_field_utf8_printf(f, "From", "%s", from);
479
 
 
480
 
                if ( to != NULL )
481
 
                        rfc2822_header_field_utf8_printf(f, "To", "%s", str_c(to));
482
 
                
483
 
                if ( cc != NULL )
484
 
                        rfc2822_header_field_utf8_printf(f, "Cc", "%s", str_c(cc));
485
 
                        
486
 
                rfc2822_header_field_printf(f, "Auto-Submitted", 
487
 
                        "auto-notified; owner-email=\"%s\"", recipient);
488
 
                rfc2822_header_field_write(f, "Precedence", "bulk");
489
 
 
490
 
                /* Set importance */
491
 
                switch ( nact->importance ) {
492
 
                case 1:
493
 
                        rfc2822_header_field_write(f, "X-Priority", "1 (Highest)");
494
 
                        rfc2822_header_field_write(f, "Importance", "High");
495
 
                        break;
496
 
                case 3:
497
 
                        rfc2822_header_field_write(f, "X-Priority", "5 (Lowest)");
498
 
                        rfc2822_header_field_write(f, "Importance", "Low");
499
 
                        break;
500
 
                case 2:
501
 
                default:
502
 
                        rfc2822_header_field_write(f, "X-Priority", "3 (Normal)");
503
 
                        rfc2822_header_field_write(f, "Importance", "Normal");
504
 
                        break;
505
 
                }
506
 
                
507
 
                /* Add custom headers */
508
 
                
509
 
                headers = array_get(&mtctx->uri->headers, &hcount);
510
 
                for ( h = 0; h < hcount; h++ ) {
511
 
                        const char *name = rfc2822_header_field_name_sanitize(headers[h].name);
512
 
                
513
 
                        rfc2822_header_field_write(f, name, headers[h].body);
514
 
                }
515
 
                        
516
 
                /* Generate message body */
517
 
                if ( body != NULL ) {
518
 
                        if (_contains_8bit(body)) {
519
 
                                rfc2822_header_field_write(f, "MIME-Version", "1.0");
520
 
                                rfc2822_header_field_write
521
 
                                        (f, "Content-Type", "text/plain; charset=UTF-8");
522
 
                                rfc2822_header_field_write(f, "Content-Transfer-Encoding", "8bit");
523
 
                        }
524
 
                        
525
 
                        fprintf(f, "\r\n");
526
 
                        fprintf(f, "%s\r\n", body);
527
 
                        
528
 
                } else {
529
 
                        fprintf(f, "\r\n");
530
 
                        fprintf(f, "Notification of new message.\r\n");
531
 
                }
532
 
        
 
539
                        (senv, recipients[i].normalized, from_smtp, &output);
 
540
 
 
541
                o_stream_send(output, str_data(msg), str_len(msg));
 
542
 
533
543
                if ( sieve_smtp_close(senv, smtp_handle) ) {
534
 
                        sieve_enotify_global_info(nenv, 
535
 
                                "sent mail notification to <%s>", 
 
544
                        sieve_enotify_global_info(nenv,
 
545
                                "sent mail notification to <%s>",
536
546
                                str_sanitize(recipients[i].normalized, 80));
537
547
                } else {
538
548
                        sieve_enotify_global_error(nenv,
539
549
                                "failed to send mail notification to <%s> "
540
 
                                "(refer to system log for more information)", 
 
550
                                "(refer to system log for more information)",
541
551
                                str_sanitize(recipients[i].normalized, 80));
542
552
                }
543
553
        }
546
556
}
547
557
 
548
558
static bool ntfy_mailto_action_execute
549
 
(const struct sieve_enotify_exec_env *nenv, 
 
559
(const struct sieve_enotify_exec_env *nenv,
550
560
        const struct sieve_enotify_action *nact)
551
561
{
552
562
        const char *const *headers;
553
563
        const char *sender = sieve_message_get_sender(nenv->msgctx);
554
564
        const char *recipient = sieve_message_get_final_recipient(nenv->msgctx);
 
565
        bool result;
555
566
 
556
 
        /* Is the recipient unset? 
 
567
        /* Is the recipient unset?
557
568
         */
558
569
        if ( recipient == NULL ) {
559
 
                sieve_enotify_global_warning(nenv, 
 
570
                sieve_enotify_global_warning(nenv,
560
571
                        "notify mailto action aborted: envelope recipient is <>");
561
572
                return TRUE;
562
573
        }
563
 
        
 
574
 
564
575
        /* Is the message an automatic reply ? */
565
576
        if ( mail_get_headers
566
577
                (nenv->msgdata->mail, "auto-submitted", &headers) >= 0 ) {
569
580
                /* Theoretically multiple headers could exist, so lets make sure */
570
581
                while ( *hdsp != NULL ) {
571
582
                        if ( strcasecmp(*hdsp, "no") != 0 ) {
572
 
                                sieve_enotify_global_info(nenv, 
573
 
                                        "not sending notification for auto-submitted message from <%s>", 
 
583
                                sieve_enotify_global_info(nenv,
 
584
                                        "not sending notification for auto-submitted message from <%s>",
574
585
                                        str_sanitize(sender, 128));
575
586
                                        return TRUE;
576
587
                        }
578
589
                }
579
590
        }
580
591
 
581
 
        return ntfy_mailto_send(nenv, nact, recipient);
 
592
        T_BEGIN {
 
593
                result = ntfy_mailto_send(nenv, nact, recipient);
 
594
        } T_END;
 
595
 
 
596
        return result;
582
597
}
583
598
 
584
599