Problem with sendmail and procmail

Problem with sendmail and procmail

am 12.05.2005 13:58:36 von Wolfgang Bauer

I have some problem with sendmail and procmail.
Sendmail 8.13.1 from original SuSE 9.2 is running on our machine.

I have created some procmailrc-input in /etc/procmailrc
But sendmail seems not to parse that file or runs procmail.
But when I'm setting the mailertable in /etc/mail/mailertable like this

domain.tld procmail:[10.1.1.10]
instead of
domain.tld smtp:[10.1.1.10]

sendmail actually parses the /etc/procmailrc file and do the action from the
procmailrc file (in this case he deletes the attachments like exe, com, bat,
etc.), but the mail should be forwarded to another mail-server. But now
sendmail produces some error, and the mail do not get forwarded to
10.1.1.10, as smtp:[10.1.1.10] does that:

May 12 13:34:00 host sendmail[7744]: j4CBXxi4007741: to=,
delay=00:00:01, xdelay=00:00:00, mailer=procmail, pri=122999,
relay=[10.1.1.10], dsn=5.0.0, stat=Can't create output
May 12 13:34:00 host sendmail[7744]: j4CBXxi4007741: j4CBY0i4007744: DSN:
Can't create output

Is there a possibility to script procmailrc like this, that after
modfication of the mail (attachment deletion), he forwards it to another
server via smtp to the origin recepient, if no unallowed attachment is
found?
Or why the procmailrc is not activated by default without the mailertable
definition?

Here's the procmailrc script:

:0
* < 256000
* ! ^Content-Type: text/plain
{
:0B
*
^(Content-(Type|Disposition):.*|[ ]*(file)?)name=("[^"]*|[^ ]*)\.(bat|cmd|com|exe|js|pif|scr)
/dev/null
}

Re: Problem with sendmail and procmail

am 12.05.2005 15:22:44 von Alan Connor

On comp.mail.misc, in <1115898936.15030@dns2.jm-data.at>,
"Wolfgang Bauer" wrote:

> I have some problem with sendmail and procmail. Sendmail
> 8.13.1 from original SuSE 9.2 is running on our machine.
>

> I have created some procmailrc-input in /etc/procmailrc
> But sendmail seems not to parse that file or runs procmail.
> But when I'm setting the mailertable in /etc/mail/mailertable like this
>
> domain.tld procmail:[10.1.1.10]
> instead of
> domain.tld smtp:[10.1.1.10]
>

> sendmail actually parses the /etc/procmailrc file and do the
> action from the procmailrc file (in this case he deletes the
> attachments like exe, com, bat, etc.), but the mail should be
> forwarded to another mail-server. But now sendmail produces
> some error, and the mail do not get forwarded to 10.1.1.10, as
> smtp:[10.1.1.10] does that:
>
> May 12 13:34:00 host sendmail[7744]: j4CBXxi4007741:
> to=, delay=00:00:01, xdelay=00:00:00,
> mailer=procmail, pri=122999, relay=[10.1.1.10], dsn=5.0.0,
> stat=Can't create output May 12 13:34:00 host sendmail[7744]:
> j4CBXxi4007741: j4CBY0i4007744: DSN: Can't create output
>

I don't get the above, which is probably as much my fault as
yours, but MTAs usually send the mail to procmail via a .forward
file:



Find out where the "procmail" program is located on your
system by typing "which procmail". Assume below that you
get "/usr/local/bin/procmail". Also check what your id is:
"whoami". Assume that you get "myid".

Next comes the crucial step. Put the following line in your
"~/.forward" file. Include the quotes (") into the ~/.forward
file contents. "|IFS=' ' && exec /usr/local/bin/procmail || exit
75 #myid" Set adequate permissions for accessing the "~/.forward"
file: "chmod 644 ~/.forward". Lastly, check (" ls -lFd ~/") that
your main directory permissions are at least (the equivalent of)
"drwx--s--x". If not, " chmod u+rwx ~/" and "chmod og+x ~/".



http://www.uwasa.fi/~ts/info/proctips.html>


> Is there a possibility to script procmailrc like this, that
> after modfication of the mail (attachment deletion), he
> forwards it to another server via smtp to the origin recepient,
> if no unallowed attachment is found?



>
> Here's the procmailrc script:
>

quotes removed for clarity, and edited:

:0
* < 256000
* ! ^Content-Type: text/plain
{
:0B
* ^(Content-(Type|Disposition):.*|[ ]*(file)?)name=("[^"]*|[^ ]*)\.(bat|cmd|com|exe|js|pif|scr)
| sed '1d;/boundary regex/,$d' | $SENDMAIL -t

:0
| sed '1d' | $SENDMAIL -t

}

I think that will work. Strip off the From header from
the mail, and the attachment (you'll have to come up with the
boundary regex yourself) and send it off, or just the From
header and send it off.

Maybe you'd need to strip any Status headers too. Don't know.
Simple to add another sed recipe to do this.

Not sure what you mean by "another server". You'll have to use
YOUR server to get it to another server...

You might want to use other options to $SENDMAIL.

AC

--
alanconnor AT earthlink DOT net
Use your real return address or I'll never know you
even tried to mail me. http://tinyurl.com/2t5kp

Re: Problem with sendmail and procmail

am 12.05.2005 16:34:00 von Andrzej Adam Filip

Wolfgang Bauer wrote:
> I have some problem with sendmail and procmail.
> Sendmail 8.13.1 from original SuSE 9.2 is running on our machine.
>
> I have created some procmailrc-input in /etc/procmailrc
> But sendmail seems not to parse that file or runs procmail.
> But when I'm setting the mailertable in /etc/mail/mailertable like this
>
> domain.tld procmail:[10.1.1.10]
> instead of
> domain.tld smtp:[10.1.1.10]

procmail mailer expects different "mailertable argument" than smtp
mailer. It expects name of procmail script. The pbvious localtion of
such scripts is /etc/procmailrcs/*

domain.tld procmail:_name_of_procmail_script_

> sendmail actually parses the /etc/procmailrc file and do the action from the
> procmailrc file (in this case he deletes the attachments like exe, com, bat,
> etc.), but the mail should be forwarded to another mail-server. But now
> sendmail produces some error, and the mail do not get forwarded to
> 10.1.1.10, as smtp:[10.1.1.10] does that:
>
> May 12 13:34:00 host sendmail[7744]: j4CBXxi4007741: to=,
> delay=00:00:01, xdelay=00:00:00, mailer=procmail, pri=122999,
> relay=[10.1.1.10], dsn=5.0.0, stat=Can't create output
> May 12 13:34:00 host sendmail[7744]: j4CBXxi4007741: j4CBY0i4007744: DSN:
> Can't create output

Sendmail tried to execute:
procmail -Y -m [10.1.1.10] _envelop_sender_ _recipient_

You see procmail reaction to "non existing procmail script".

> Is there a possibility to script procmailrc like this, that after
> modfication of the mail (attachment deletion), he forwards it to another
> server via smtp to the origin recepient, if no unallowed attachment is
> found?
> Or why the procmailrc is not activated by default without the mailertable
> definition?
>
> Here's the procmailrc script:
>
> :0
> * < 256000
> * ! ^Content-Type: text/plain
> {
> :0B
> *
> ^(Content-(Type|Disposition):.*|[ ]*(file)?)name=("[^"]*|[^ ]*)\.(bat|cmd|com|exe|js|pif|scr)
> /dev/null
> }

You have missed "forward to another host" part of your procmail script.

BTW default configuration of procmail mailer makes it process "one
recipient at once". It may create performance problems for multi
recipients messages but it can be easily changed.

--
Andrzej [en:Andrew] Adam Filip anfi@priv.onet.pl anfi@xl.wp.pl