3 messages in net.sourceforge.lists.courier-maildrop[maildropl] Feature proposal
FromSent OnAttachments
Przemyslaw WegrzynApr 25, 2004 3:11 pm.patch
Martin List-PetersenApr 25, 2004 5:18 pm 
Nick SimicichMay 2, 2004 1:33 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:[maildropl] Feature proposalActions...
From:Przemyslaw Wegrzyn (czaj@czajsoft.pl)
Date:Apr 25, 2004 3:11:40 pm
List:net.sourceforge.lists.courier-maildrop
Attachments:

Hi!

I'm using the following construct to send SMS notifcations on each incoming e-mail:

cc "|/usr/bin/sendsms 123123123"

The problem is, that I don't want sendsms (perl script) to be injected with full message body. I'd rather it close stdin as soon as it collects all necessary headers and/or body parts.

If the script closes its STDIN before reading the whole message, maildrop treats it as an error and exits with EX_TEMPFAIL. I'd like to force maildrop to ignore pipe write errors when needed (but of course still care about exit status, and exec() failures). I've done a patch that allows using '%' in place of '|' when such behavior is needed.

Could such feature be included in future maildrop releases ?

Best Regards, -=Czaj-nick=-

diff -ruN maildrop-1.5.3/maildrop/deliver.C
maildrop-1.5.3.sitenet/maildrop/deliver.C --- maildrop-1.5.3/maildrop/deliver.C 2004-04-04 19:52:01.000000000 +0200 +++ maildrop-1.5.3.sitenet/maildrop/deliver.C 2004-04-24 11:48:08.000000000
+0200 @@ -52,7 +52,7 @@ DeliverDotLock dotlock; Buffer b;

- if ( *mailbox == '!' || *mailbox == '|' ) + if ( *mailbox == '!' || *mailbox == '|' || *mailbox == '%' ) { Buffer cmdbuf;

@@ -124,9 +124,9 @@ pipe.fds[1]= -1; format_mbox.Init(0);

- int rc=format_mbox.DeliverTo(pipemio); + int rc=format_mbox.DeliverTo(pipemio, (*mailbox == '%') ? 1 : 0); int wait_stat; - + while (wait(&wait_stat) != pid) ; log(mailbox, rc || wait_stat, format_mbox); diff -ruN maildrop-1.5.3/maildrop/formatmbox.C
maildrop-1.5.3.sitenet/maildrop/formatmbox.C --- maildrop-1.5.3/maildrop/formatmbox.C 2002-04-08 17:11:02.000000000 +0200 +++ maildrop-1.5.3.sitenet/maildrop/formatmbox.C 2004-04-25 18:10:48.000000000
+0200 @@ -131,7 +131,7 @@ return (0); // END OF FILE }

-int FormatMbox::DeliverTo(class Mio &mio) +int FormatMbox::DeliverTo(class Mio &mio, int ignore_epipe) { Buffer *bufptr;

@@ -140,9 +140,16 @@ if (mio.write((const char *)*bufptr, bufptr->Length()) < 0) { write_error: - merr << "maildrop: error writing to mailbox.\n"; - mio.Close(); - return (-1); + /* unfrotunately, we can't check errno here, because mio.write() returns -1 + * not when it gets EPIPE, but in a subsequnet call. */ + if (ignore_epipe) { + mio.Close(); + return 0; + } else { + mio.Close(); + merr << "maildrop: error writing to mailbox.\n"; + return (-1); + } } }

diff -ruN maildrop-1.5.3/maildrop/formatmbox.h
maildrop-1.5.3.sitenet/maildrop/formatmbox.h --- maildrop-1.5.3/maildrop/formatmbox.h 1998-04-17 02:08:53.000000000 +0200 +++ maildrop-1.5.3.sitenet/maildrop/formatmbox.h 2004-04-24 12:03:17.000000000
+0200 @@ -57,6 +57,6 @@ return ( (this->*next_func)() ); }

- int DeliverTo(class Mio &); + int DeliverTo(class Mio &, int ignore_epipe = 0); } ; #endif