]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Added rejection_subject setting to deliver, which is used for rejected mails.
authorTimo Sirainen <tss@iki.fi>
Tue, 13 Jan 2009 21:55:03 +0000 (16:55 -0500)
committerTimo Sirainen <tss@iki.fi>
Tue, 13 Jan 2009 21:55:03 +0000 (16:55 -0500)
Based on patch by Allan Cassaro.

--HG--
branch : HEAD

dovecot-example.conf
src/deliver/deliver.c
src/deliver/deliver.h
src/deliver/mail-send.c

index 91c07d37b50828f4707b810b568b7c6317b713bf..b54e14cbe1cb20059c3eef24a34544ed6a30329d 100644 (file)
@@ -712,8 +712,12 @@ protocol lda {
   # Binary to use for sending mails.
   #sendmail_path = /usr/lib/sendmail
 
-  # Human readable error message for rejection mails. Use can use variables:
-  #  %n = CRLF, %r = reason, %s = subject, %t = recipient
+  # Subject: header to use for rejection mails. You can use the same variables
+  # as for rejection_reason below.
+  #rejection_subject = Automatically rejected mail
+
+  # Human readable error message for rejection mails. You can use variables:
+  #  %n = CRLF, %r = reason, %s = original subject, %t = recipient
   #rejection_reason = Your message to <%t> was automatically rejected:%n%r
 
   # UNIX socket path to master authentication server to find users.
index 7f2fddda933d6c88a8e7e9edf5a073926332c80e..6342a71f171ac65fbbfbda406f73ececc93630cf 100644 (file)
@@ -1048,6 +1048,9 @@ int main(int argc, char *argv[])
        deliver_set->sendmail_path = getenv("SENDMAIL_PATH");
        if (deliver_set->sendmail_path == NULL)
                deliver_set->sendmail_path = DEFAULT_SENDMAIL_PATH;
+       deliver_set->rejection_subject = getenv("REJECTION_SUBJECT");
+       if (deliver_set->rejection_subject == NULL)
+               deliver_set->rejection_subject = DEFAULT_MAIL_REJECTION_SUBJECT;
        deliver_set->rejection_reason = getenv("REJECTION_REASON");
        if (deliver_set->rejection_reason == NULL) {
                deliver_set->rejection_reason =
index 1ea2b6ba73756715e5a236738c9d894a9aabe3dd..69b6c9949bce3d1a78c51ed0cd7b9078ef4e4098 100644 (file)
@@ -10,6 +10,8 @@
 #include "lib.h"
 #include "mail-storage.h"
 
+#define DEFAULT_MAIL_REJECTION_SUBJECT \
+       "Automatically rejected mail"
 #define DEFAULT_MAIL_REJECTION_HUMAN_REASON \
        "Your message to <%t> was automatically rejected:%n%r"
 #define DEFAULT_LOG_FORMAT "msgid=%m: %$"
@@ -18,6 +20,7 @@ struct deliver_settings {
        const char *hostname;
        const char *postmaster_address;
        const char *sendmail_path;
+       const char *rejection_subject;
        const char *rejection_reason;
        const char *log_format;
        bool mailbox_autosubscribe;
index bd32cd0409236a11379537fcdc1b33a126e17c43..41d89f7cb53f91671af62a3dabb4960b7995d268 100644 (file)
@@ -54,10 +54,10 @@ int mail_send_rejection(struct mail *mail, const char *recipient,
     struct smtp_client *smtp_client;
     FILE *f;
     struct message_size hdr_size;
-    const char *return_addr, *str;
+    const char *return_addr, *hdr;
     const unsigned char *data;
     const char *msgid, *orig_msgid, *boundary;
-    string_t *human_reason;
+    string_t *str;
     size_t size;
     int ret;
 
@@ -90,7 +90,12 @@ int mail_send_rejection(struct mail *mail, const char *recipient,
     fprintf(f, "Content-Type: "
            "multipart/report; report-type=disposition-notification;\r\n"
            "\tboundary=\"%s\"\r\n", boundary);
-    fprintf(f, "Subject: Automatically rejected mail\r\n");
+
+    str = t_str_new(256);
+    var_expand(str, deliver_set->rejection_subject,
+              get_var_expand_table(mail, reason, recipient));
+    fprintf(f, "Subject: %s\r\n", str_c(str));
+
     fprintf(f, "Auto-Submitted: auto-replied (rejected)\r\n");
     fprintf(f, "Precedence: bulk\r\n");
     fprintf(f, "\r\nThis is a MIME-encapsulated message\r\n\r\n");
@@ -101,10 +106,10 @@ int mail_send_rejection(struct mail *mail, const char *recipient,
     fprintf(f, "Content-Disposition: inline\r\n");
     fprintf(f, "Content-Transfer-Encoding: 8bit\r\n\r\n");
 
-    human_reason = t_str_new(256);
-    var_expand(human_reason, deliver_set->rejection_reason,
+    str_truncate(str, 0);
+    var_expand(str, deliver_set->rejection_reason,
               get_var_expand_table(mail, reason, recipient));
-    fprintf(f, "%s\r\n", str_c(human_reason));
+    fprintf(f, "%s\r\n", str_c(str));
 
     /* MDN status report */
     fprintf(f, "--%s\r\n"
@@ -112,8 +117,8 @@ int mail_send_rejection(struct mail *mail, const char *recipient,
            boundary);
     fprintf(f, "Reporting-UA: %s; Dovecot Mail Delivery Agent\r\n",
            deliver_set->hostname);
-    if (mail_get_first_header(mail, "Original-Recipient", &str) > 0)
-           fprintf(f, "Original-Recipient: rfc822; %s\r\n", str);
+    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 (orig_msgid != NULL)