Simple filter via pipe

2009-08-31 Thread none none
I've created this simple_filter:
http://www.postfix.org/FILTER_README.html#simple_filter

This is email, being sent via sendmail command, after it has been filtered:

Received: from [192.168.0.3] (unknown [192.168.0.3])
(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
(No client certificate requested)
by khole.example1.com (Postfix) with ESMTPSA id 5EDEC11425
for j...@example2.com; Sun, 23 Aug 2009 18:15:02 +0200 (CEST)
Message-ID: 4a9aa581.3050...@starforce.biz
Date: Sun, 23 Aug 2009 18:14:57 +0200
From: Root r...@example1.com
User-Agent: Thunderbird 2.0.0.23 (Windows/20090812)
MIME-Version: 1.0
To: j...@example2.com
Subject: Is it in?
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

I think it should not be.



Filter is using this command:
/usr/local/sbin/sendmail -G -i -f r...@example1.com j...@example2.com
msg-headers+body-from-above

I have 2 problems

Above command, if used as a root user results in MODIFIED headers+body
msg-headers+body MUST be exactly same, after it pass through filter
and STAY that way, until it leaves my server.
As first 2 lines below shows, another Received: header, has been
added, as soon as it passes through sendmail

Received: by khole.example1.com (Postfix, from userid 1003)
id 1CCB111428; Mon, 23 Aug 2009 19:32:15 +0200 (CEST)
Received: from [192.168.0.3] (unknown [192.168.0.3])
(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
(No client certificate requested)
by khole.example1.com (Postfix) with ESMTPSA id 5EDEC11425
for j...@example2.com; Sun, 23 Aug 2009 18:15:02 +0200 (CEST)
Message-ID: 4a9aa581.3050...@starforce.biz
Date: Sun, 23 Aug 2009 18:14:57 +0200
From: Root r...@example1.com
User-Agent: Thunderbird 2.0.0.23 (Windows/20090812)
MIME-Version: 1.0
To: j...@example2.com
Subject: Is it in?
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

I think it should not be.


Second problem:
If msg-headers+body from begening of this post, is being sent as:
/usr/local/sbin/sendmail -G -i -f r...@example1.com j...@example2.com
msg-headers+body
AS user that is NOT root, which is filter user:
/etc/postfix/master.cf:
  # =
  # service type  private unpriv  chroot  wakeup  maxproc command
  #   (yes)   (yes)   (yes)   (never) (100)
  # =
  filterunix  -   n   n   -   10  pipe
#flags=Rq
user=filter
null_sender=
argv=.

Message is THIS:
from (unknown sender)
to (no subject)

Received: by khole.example1.com (Postfix, from userid 1003)
id 27A1711429; Mon, 23 Aug 2009 19:29:36 +0200 (CEST)

Everything is being stripped!!!


Thank in advance! ;)


Re: Simple filter via pipe

2009-08-31 Thread none none
On Mon, Aug 31, 2009 at 8:34 PM, Noel Jonesnjo...@megan.vbhcs.org wrote:
 On 8/31/2009 12:58 PM, none none wrote:

 I've created this simple_filter:
 http://www.postfix.org/FILTER_README.html#simple_filter

 This is email, being sent via sendmail command, after it has been
 filtered:

 
 Received: from [192.168.0.3] (unknown [192.168.0.3])
         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
         (No client certificate requested)
         by khole.example1.com (Postfix) with ESMTPSA id 5EDEC11425
         forj...@example2.com; Sun, 23 Aug 2009 18:15:02 +0200 (CEST)
 Message-ID:4a9aa581.3050...@starforce.biz
 Date: Sun, 23 Aug 2009 18:14:57 +0200
 From: Rootr...@example1.com
 User-Agent: Thunderbird 2.0.0.23 (Windows/20090812)
 MIME-Version: 1.0
 To: j...@example2.com
 Subject: Is it in?
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit

 I think it should not be.

 Should not be what?   It's unclear what you refer to here.

LOL!
You've deleted bottom line (...-...) which divides
mail(header + body) from this chatter.
String I think it should not be., is just a part of mail, that is, it's body.
Completely irrelevant here.


 Filter is using this command:
 /usr/local/sbin/sendmail -G -i -f r...@example1.com j...@example2.com
 msg-headers+body-from-above

 The sendmail commend is a pipe.  Don't put headers+body on the command line.

Yes I know that.Simply haven't knew how to formulate this mail comand line.
I send mail by firstly typing: /usr/local/sbin/sendmail -G -i -f
r...@example1.com j...@example2.com
Then I hit enter. Then I paste mail(header + body).
Then I hit:
^D



 I have 2 problems

 Above command, if used as a root user results in MODIFIED headers+body
 msg-headers+body MUST be exactly same, after it pass through filter
 and STAY that way, until it leaves my server.
 As first 2 lines below shows, another Received: header, has been
 added, as soon as it passes through sendmail

 
 Received: by khole.example1.com (Postfix, from userid 1003)
        id 1CCB111428; Mon, 23 Aug 2009 19:32:15 +0200 (CEST)

 Yes, postfix adds a Received: header when a mail is received.  There is no
 option to turn this off.

Postfix has already received relayed mail and added first Received: header
Then it came into my filter.
After filter has done it's job, it send it back to potfix by using
/usr/local/sbin/sendmail, which adds ANOTHER Received: header
Nothing should touch or add anything to mail header or it's body,
after filter has done it's job!


 You may be able to later remove the header with an appropriate header_checks
 entry, but be careful when removing headers.

That is not an option


 Second problem:
 If msg-headers+body from begening of this post, is being sent as:
 /usr/local/sbin/sendmail -G -i -f r...@example1.com j...@example2.com
 msg-headers+body

 The sendmail command is a pipe.

I've gave you exact example of how I use sendmail command
You've also deleted key part here.
If that sendmail command is being executed as a ROOT, then mail ends
up in target mailbox as I showed.

BUT, after I've created user filter and set it as owner and
executioner of filter proces in master.cf
In target mailbox I get mail like this:


from (unknown sender)
to (no subject)

Received: by khole.example1.com (Postfix, from userid 1003)
id 27A1711429; Mon, 23 Aug 2009 19:29:36 +0200 (CEST)


Everything is being stripped!!!
Only that has been left is a SECOND header added by sendmail command.

In mail log I see:
postfix/cleanup[17465]: C473511429: message-id=

It does it? But NOT for root user


 If you describe what original problem you're trying to solve maybe you can
 get some better pointers.


  -- Noel Jones


Done Noel!
;)


Building milter in PHP

2009-08-22 Thread none none
I've setup postfix for before queue
I have not chosen to install milter but to create my own.

I did that in PHP.

Now, I am at a part, where my PHP milter has to communicate with postfix.

Aim is to get string from postfix, evaluate it and send it back to postfix.
So I started to read as a first action.

Errors I did received were:
can't read SMFIC_OPTNEG reply packet header: Operation timed out

At that point I've figured out that PHP milter has to say something to postfix
So I've sent string Hello! Killer here, send me a victim!


unreasonable packet length: 1265200236  1073741823
At that point I've figured out that PHP milter is sending to long
welcome message.

Then I've sent just a dot .


EOF while reading command code: Operation timed out
A-ha!
So here is a catch! COMMAND!

postfix and each milter, have some string commands, they use to comunicate.

So please can anyone give me a link to those command(Something to do with DEV)
;)

So I could finish my PHP milter(DA KILLA!)


Special needs(filter - SASL)

2009-08-19 Thread none none
I would like email to be filtered ONLY from user that relays(SASL
authed) mail to the outside(not localhost) mailbox.
That is, if that same user is sending mail from local machine(no
relaying) then filter doesn't kicks in.

I've looked at postfix man pages and documentation and it is too much
hassle about creating other instances of smtp ot smtpd etc... and pcre
has limited caps for me.

I am very skilled when it comes to PHP, so would like to create PHP
script that would suck that mail in and spit it out for delivery by
postfix.

But Right now I would be happy even with in /usr/local/etc/postfix/main.cf:
header_checks = pcre:/usr/local/etc/postfix/strip_relay_header

BUT, that header_checks rule should kick in ONLY for remote SASL
authed user when target mailbox is NOT locally hosted (goes out to the
internet)


transport maps override

2009-05-20 Thread none none

Good Afternoon and excuse my poor english.

We are running postfix 2.3.3. on a Redhat ES 5.1
We are receiving mail for two domains:
a) domain.com
b) customers.domain.com

Recently a company that we cooperate with, asked us to 
forward all the e-mails sent to them (for security reasons) 
from domain.com to an 
alternative SMTP (othersmtp.company.com) that is 
other than the company's primary MX.
We implemented this, by modifying the /etc/postfix/transport file, 
and it worked like a charm.

The problem is that we would like to override the above rule for the domain
customers.domain.com. So when someone from customers.domain.com sends e-mail to 
company.com
that mail is sent to the company's primary MX and not via othersmtp.company.com.

Any help will be deeply appreciated

_
More than messages–check out the rest of the Windows Live™.
http://www.microsoft.com/windows/windowslive/