Mercurial > dovecot > core-2.2
changeset 14132:ad5298ba3229
lib-lda: Send DSN only for out-of-quota errors. Send MDN for Sieve rejects.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 12 Feb 2012 18:26:22 +0200 |
parents | b9e74767cd39 |
children | ba770cba5598 |
files | src/lda/main.c src/lib-lda/mail-deliver.h src/lib-lda/mail-send.c |
diffstat | 3 files changed, 35 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lda/main.c Sun Feb 12 07:25:40 2012 +0200 +++ b/src/lda/main.c Sun Feb 12 18:26:22 2012 +0200 @@ -454,6 +454,7 @@ return EX_TEMPFAIL; } ctx.mailbox_full = TRUE; + ctx.dsn = TRUE; /* we'll have to reply with permanent failure */ mail_deliver_log(&ctx, "rejected: %s",
--- a/src/lib-lda/mail-deliver.h Sun Feb 12 07:25:40 2012 +0200 +++ b/src/lib-lda/mail-deliver.h Sun Feb 12 18:26:22 2012 +0200 @@ -53,6 +53,8 @@ bool save_dest_mail; /* Delivery failed because user is out of quota / disk space */ bool mailbox_full; + /* Send DSN instead of MDN */ + bool dsn; }; struct mail_deliver_save_open_context {
--- a/src/lib-lda/mail-send.c Sun Feb 12 07:25:40 2012 +0200 +++ b/src/lib-lda/mail-send.c Sun Feb 12 18:26:22 2012 +0200 @@ -99,8 +99,10 @@ fprintf(f, "To: <%s>\r\n", return_addr); fprintf(f, "MIME-Version: 1.0\r\n"); fprintf(f, "Content-Type: " - "multipart/report; report-type=delivery-status;\r\n" - "\tboundary=\"%s\"\r\n", boundary); + "multipart/report; report-type=%s;\r\n" + "\tboundary=\"%s\"\r\n", + ctx->dsn ? "delivery-status" : "disposition-notification", + boundary); str = t_str_new(256); var_expand(str, ctx->set->rejection_subject, @@ -122,18 +124,35 @@ get_var_expand_table(mail, reason, recipient)); fprintf(f, "%s\r\n", str_c(str)); - /* DSN status report */ - fprintf(f, "--%s\r\n" - "Content-Type: message/delivery-status\r\n\r\n", - boundary); - fprintf(f, "Reporting-MTA: dns; %s\r\n", - ctx->set->hostname); - if (mail_get_first_header(mail, "Original-Recipient", &hdr) > 0) - fprintf(f, "Original-Recipient: rfc822; %s\r\n", hdr); - fprintf(f, "Final-Recipient: rfc822; %s\r\n", recipient); + if (ctx->dsn) { + /* DSN status report: For LDA rejects. currently only used when + user is out of quota */ + fprintf(f, "--%s\r\n" + "Content-Type: message/delivery-status\r\n\r\n", + boundary); + fprintf(f, "Reporting-MTA: dns; %s\r\n", + ctx->set->hostname); + if (mail_get_first_header(mail, "Original-Recipient", &hdr) > 0) + fprintf(f, "Original-Recipient: rfc822; %s\r\n", hdr); + fprintf(f, "Final-Recipient: rfc822; %s\r\n", recipient); + fprintf(f, "Action: failed\r\n"); + fprintf(f, "Status: %s\r\n", ctx->mailbox_full ? "5.2.2" : "5.2.0"); + } else { + /* MDN status report: For Sieve "reject" */ + fprintf(f, "--%s\r\n" + "Content-Type: message/disposition-notification\r\n\r\n", + boundary); + fprintf(f, "Reporting-UA: %s; Dovecot Mail Delivery Agent\r\n", + ctx->set->hostname); + if (mail_get_first_header(mail, "Original-Recipient", &hdr) > 0) + fprintf(f, "Original-Recipient: rfc822; %s\r\n", hdr); + fprintf(f, "Final-Recipient: rfc822; %s\r\n", recipient); - fprintf(f, "Action: failed\r\n"); - fprintf(f, "Status: %s\r\n", ctx->mailbox_full ? "5.2.2" : "5.2.0"); + if (orig_msgid != NULL) + fprintf(f, "Original-Message-ID: %s\r\n", orig_msgid); + fprintf(f, "Disposition: " + "automatic-action/MDN-sent-automatically; deleted\r\n"); + } fprintf(f, "\r\n"); /* original message's headers */