dovecot-1.2: Added rejection_subject setting to deliver, which i...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Jan 13 23:59:03 EET 2009
details: http://hg.dovecot.org/dovecot-1.2/rev/2fa464fd3aab
changeset: 8622:2fa464fd3aab
user: Timo Sirainen <tss at iki.fi>
date: Tue Jan 13 16:55:03 2009 -0500
description:
Added rejection_subject setting to deliver, which is used for rejected mails.
Based on patch by Allan Cassaro.
diffstat:
4 files changed, 25 insertions(+), 10 deletions(-)
dovecot-example.conf | 8 ++++++--
src/deliver/deliver.c | 3 +++
src/deliver/deliver.h | 3 +++
src/deliver/mail-send.c | 21 +++++++++++++--------
diffs (106 lines):
diff -r 22985329af92 -r 2fa464fd3aab dovecot-example.conf
--- a/dovecot-example.conf Tue Jan 13 13:13:19 2009 -0500
+++ b/dovecot-example.conf Tue Jan 13 16:55:03 2009 -0500
@@ -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.
diff -r 22985329af92 -r 2fa464fd3aab src/deliver/deliver.c
--- a/src/deliver/deliver.c Tue Jan 13 13:13:19 2009 -0500
+++ b/src/deliver/deliver.c Tue Jan 13 16:55:03 2009 -0500
@@ -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 =
diff -r 22985329af92 -r 2fa464fd3aab src/deliver/deliver.h
--- a/src/deliver/deliver.h Tue Jan 13 13:13:19 2009 -0500
+++ b/src/deliver/deliver.h Tue Jan 13 16:55:03 2009 -0500
@@ -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;
diff -r 22985329af92 -r 2fa464fd3aab src/deliver/mail-send.c
--- a/src/deliver/mail-send.c Tue Jan 13 13:13:19 2009 -0500
+++ b/src/deliver/mail-send.c Tue Jan 13 16:55:03 2009 -0500
@@ -54,10 +54,10 @@ int mail_send_rejection(struct mail *mai
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 *mai
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 *mai
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 *mai
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)
More information about the dovecot-cvs
mailing list