Re: [EXIM] multipart/report delivery status messages

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Paul Makepeace
Datum:  
To: exim-users
Betreff: Re: [EXIM] multipart/report delivery status messages
On Fri, Jun 25, 1999 at 06:59:46PM -0500, Paul Makepeace wrote:
> Is there any work going/gone on/planned to enable exim to report delivery
> status notifications using RFC1892 multipart/report MIME messages? At


I had to rush out on Friday and didn't have time to post this, but here
is a hacky stab at implementing MIME'd bounce messages. It makes use
of embedded perl and smiling gods. By the latter I mean exim provides
just enough functionality in the right way that it's actually just
about do-able. I use the 'text' and 'return_message' features of
the 'autoreply' transport along with a minor source patch.

exim.conf, transport section:

bounce:
driver = autoreply
return_message
user = exim
group = mail
to = $sender_address
subject = "Unable to deliver to ${local_part}@${domain}"
headers = "Mime-Version: 1.0\nContent-Type: multipart/mixed; boundary=\"${per
l{mime_boundary}}\""
text = ${perl{mime_bounce}}
log = "/var/spool/exim/log/bouncelog"

exim.pl, run from inetd so this static invocation will need tiny extra
work for daemon mode. Better boundaries gratefully accepted:

my $mime_boundary = "WishThatM1MewaSn-tsucHaPain666" . sprintf("%x%x", $$, rand $$);

sub mime_boundary { $mime_boundary }

sub mime_bounce {
        my $gripe = failure_message();
        my $subject = Exim::expand_string('$h_Subject');


        return <<TEXT;
This is a MIME multipart message. Upgrade your email client today!


--$mime_boundary
Content-type: text/plain; charset=iso-8859-1

$gripe

--$mime_boundary
Content-type: message/rfc822
Content-Disposition: attachment; filename="$subject"

TEXT
}

src/transports/autoreply.c to not include the "This is a copy..." message
which otherwise prevents parsing headers as headers:

    else ; /* fprintf(f, "\n"
"------ This is a copy of the message, including all the headers. ------\n\n");
*/
    }
  else ; /* fprintf(f, "\n"
"------ This is a copy of the message, including all the headers. ------\n\n");
*/


so the headers would be treated as headers within a MIME section.

Observant folk will notice that this "hack headers, return mime 'text'
and 'return_message'" leaves off the final MIME boundary. While I dislike
this a lot it hasn't seemed to cause any clients to incorrectly display
it (altho' I've yet to try Eudora...). It even got through an Exchange
gateway OK.

I've tried it with HTML messages with embedded images and even forwarding
the output of a bounce back to a failing address and (at least) Outlook
Express and mutt can unpack it all correctly.

Cheers,
Paul

--
*** Exim information can be found at http://www.exim.org/ ***