100
99
fprintf(f, "To: <%s>\r\n", return_addr);
101
100
fprintf(f, "MIME-Version: 1.0\r\n");
102
101
fprintf(f, "Content-Type: "
103
"multipart/report; report-type=disposition-notification;\r\n"
104
"\tboundary=\"%s\"\r\n", boundary);
102
"multipart/report; report-type=%s;\r\n"
103
"\tboundary=\"%s\"\r\n",
104
ctx->dsn ? "delivery-status" : "disposition-notification",
106
107
str = t_str_new(256);
107
108
var_expand(str, ctx->set->rejection_subject,
123
124
get_var_expand_table(mail, reason, recipient));
124
125
fprintf(f, "%s\r\n", str_c(str));
126
/* MDN status report */
127
fprintf(f, "--%s\r\n"
128
"Content-Type: message/disposition-notification\r\n\r\n",
130
fprintf(f, "Reporting-UA: %s; Dovecot Mail Delivery Agent\r\n",
132
if (mail_get_first_header(mail, "Original-Recipient", &hdr) > 0)
133
fprintf(f, "Original-Recipient: rfc822; %s\r\n", hdr);
134
fprintf(f, "Final-Recipient: rfc822; %s\r\n", recipient);
128
/* DSN status report: For LDA rejects. currently only used when
129
user is out of quota */
130
fprintf(f, "--%s\r\n"
131
"Content-Type: message/delivery-status\r\n\r\n",
133
fprintf(f, "Reporting-MTA: dns; %s\r\n",
135
if (mail_get_first_header(mail, "Original-Recipient", &hdr) > 0)
136
fprintf(f, "Original-Recipient: rfc822; %s\r\n", hdr);
137
fprintf(f, "Final-Recipient: rfc822; %s\r\n", recipient);
138
fprintf(f, "Action: failed\r\n");
139
fprintf(f, "Status: %s\r\n", ctx->mailbox_full ? "5.2.2" : "5.2.0");
141
/* MDN status report: For Sieve "reject" */
142
fprintf(f, "--%s\r\n"
143
"Content-Type: message/disposition-notification\r\n\r\n",
145
fprintf(f, "Reporting-UA: %s; Dovecot Mail Delivery Agent\r\n",
147
if (mail_get_first_header(mail, "Original-Recipient", &hdr) > 0)
148
fprintf(f, "Original-Recipient: rfc822; %s\r\n", hdr);
149
fprintf(f, "Final-Recipient: rfc822; %s\r\n", recipient);
136
if (orig_msgid != NULL)
137
fprintf(f, "Original-Message-ID: %s\r\n", orig_msgid);
138
fprintf(f, "Disposition: "
139
"automatic-action/MDN-sent-automatically; deleted\r\n");
151
if (orig_msgid != NULL)
152
fprintf(f, "Original-Message-ID: %s\r\n", orig_msgid);
153
fprintf(f, "Disposition: "
154
"automatic-action/MDN-sent-automatically; deleted\r\n");
140
156
fprintf(f, "\r\n");
142
158
/* original message's headers */
143
159
fprintf(f, "--%s\r\nContent-Type: message/rfc822\r\n\r\n", boundary);
145
if (mail_get_stream(mail, &hdr_size, NULL, &input) == 0) {
161
if (mail_get_hdr_stream(mail, NULL, &input) == 0) {
146
162
/* Note: If you add more headers, they need to be sorted.
147
163
We'll drop Content-Type because we're not including the message
148
164
body, and having a multipart Content-Type may confuse some