You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by NeoSHNIK <at...@gmail.com> on 2008/10/12 21:19:47 UTC

Processing Outbound Emails Differently

Hello,
I am writing a plugin for SA which needs to treat outbound and incoming
emails differently. So ideally if the message is outbound I call one
subroutine in my plugin, if not I call another.
So is there any way to check what type of email it is in SA? I couldn't find
any.
Someone said that it is possible to run two copies of Postfix MTA - one for
incoming, other for outgoing messages. And I guess then it would run two
copies of SA with two different plugins that I write. But there has to be an
easier way to do this.
When the Postfix receives an outgoing message it stores it in the
".../Mail/send" right? So if it stores it before it calls SA my plugin could
search in that file by message-ID. Thank God string searching is easy in
Perl. 
I could also hardcode the email addresses of the users behind the server
with SA, but then it would not be safe nor would it scale with high amount
of users in the network.
Any suggestions?
Cheers
-- 
View this message in context: http://www.nabble.com/Processing-Outbound-Emails-Differently-tp19944816p19944816.html
Sent from the SpamAssassin - Users mailing list archive at Nabble.com.


Re: Processing Outbound Emails Differently

Posted by NeoSHNIK <at...@gmail.com>.


mouss-2 wrote:
> 
> NeoSHNIK a écrit :
>> Hello,
>> I am writing a plugin for SA which needs to treat outbound and incoming
>> emails differently. So ideally if the message is outbound I call one
>> subroutine in my plugin, if not I call another.
>> So is there any way to check what type of email it is in SA? I couldn't
>> find
>> any.
>> Someone said that it is possible to run two copies of Postfix MTA - one
>> for
>> incoming, other for outgoing messages. 
> 
> There is no need to run two copies.
> - the recommended way is to enable the submission service in master.cf
> and have outbound mail use port 587
> - but even if you use port 25 for both MX and submission, you can use an
> access check that returns a FILTER statement which sets different
> filters for inbound and outbound mail). a google search (or search
> postfix-users archives) will give you examples (I think I posted one
> recently).
> 
>> And I guess then it would run two
>> copies of SA with two different plugins that I write. 
> 
> This depends on your setup. There is nothing automatic here.
> 
>> But there has to be an
>> easier way to do this.
>> When the Postfix receives an outgoing message it stores it in the
>> ".../Mail/send" right? 
> No. The Sent folder has nothing to do with smtp. This folder is accessed
> by your MUA via IMAP (so you won't find it on the server if using POP3).
> 
>> So if it stores it before it calls SA my plugin could
>> search in that file by message-ID. Thank God string searching is easy in
>> Perl. 
>>   
> 
> but unreliable. any spammer can forge message-id's and other headers.
> 
>> I could also hardcode the email addresses of the users behind the server
>> with SA, but then it would not be safe nor would it scale with high
>> amount
>> of users in the network.
>>   
> 
> if you really want scale, use different machines;-p Divide and conquer...
> 
>> Any suggestions?
>>   
> 
> unless you run two instances of spamd (or amavisd-new or ...) or you run
> spamassassin command (not good for perf) with different options, SA
> doesn't know if mail is inbound or outbound. The difference between
> inbound and outbound is at reception time. In general, outbound mail
> comes from a trusted client or was sent with authentication, but this
> not necessarily true for every setup.
> 
> You could look at headers (either postfix headers or X-Relay-External).
> 
> 
mouss-2, thanks a lot for a quick and detailed response!

-- 
View this message in context: http://www.nabble.com/Processing-Outbound-Emails-Differently-tp19944816p19945959.html
Sent from the SpamAssassin - Users mailing list archive at Nabble.com.


Re: Processing Outbound Emails Differently

Posted by mouss <mo...@netoyen.net>.
NeoSHNIK a écrit :
> Hello,
> I am writing a plugin for SA which needs to treat outbound and incoming
> emails differently. So ideally if the message is outbound I call one
> subroutine in my plugin, if not I call another.
> So is there any way to check what type of email it is in SA? I couldn't find
> any.
> Someone said that it is possible to run two copies of Postfix MTA - one for
> incoming, other for outgoing messages. 

There is no need to run two copies.
- the recommended way is to enable the submission service in master.cf
and have outbound mail use port 587
- but even if you use port 25 for both MX and submission, you can use an
access check that returns a FILTER statement which sets different
filters for inbound and outbound mail). a google search (or search
postfix-users archives) will give you examples (I think I posted one
recently).

> And I guess then it would run two
> copies of SA with two different plugins that I write. 

This depends on your setup. There is nothing automatic here.

> But there has to be an
> easier way to do this.
> When the Postfix receives an outgoing message it stores it in the
> ".../Mail/send" right? 
No. The Sent folder has nothing to do with smtp. This folder is accessed
by your MUA via IMAP (so you won't find it on the server if using POP3).

> So if it stores it before it calls SA my plugin could
> search in that file by message-ID. Thank God string searching is easy in
> Perl. 
>   

but unreliable. any spammer can forge message-id's and other headers.

> I could also hardcode the email addresses of the users behind the server
> with SA, but then it would not be safe nor would it scale with high amount
> of users in the network.
>   

if you really want scale, use different machines;-p Divide and conquer...

> Any suggestions?
>   

unless you run two instances of spamd (or amavisd-new or ...) or you run
spamassassin command (not good for perf) with different options, SA
doesn't know if mail is inbound or outbound. The difference between
inbound and outbound is at reception time. In general, outbound mail
comes from a trusted client or was sent with authentication, but this
not necessarily true for every setup.

You could look at headers (either postfix headers or X-Relay-External).

Re: Processing Outbound Emails Differently

Posted by Andrzej Adam Filip <an...@onet.eu>.
NeoSHNIK <at...@gmail.com> wrote:

> Hello,
> I am writing a plugin for SA which needs to treat outbound and incoming
> emails differently. So ideally if the message is outbound I call one
> subroutine in my plugin, if not I call another.
> So is there any way to check what type of email it is in SA? I couldn't find
> any.
> Someone said that it is possible to run two copies of Postfix MTA - one for
> incoming, other for outgoing messages. And I guess then it would run two
> copies of SA with two different plugins that I write. But there has to be an
> easier way to do this.
> When the Postfix receives an outgoing message it stores it in the
> ".../Mail/send" right? So if it stores it before it calls SA my plugin could
> search in that file by message-ID. Thank God string searching is easy in
> Perl. 
> I could also hardcode the email addresses of the users behind the server
> with SA, but then it would not be safe nor would it scale with high amount
> of users in the network.
> Any suggestions?
> Cheers

Have you considered calling SA from Milter?
[ Postfix supports milters ]

I think you can make MIMEDefang.org milter call SA code differently for
incoming and outgoing messages.

-- 
[pl>en: Andrew] Andrzej Adam Filip : anfi@onet.eu : anfi@xl.wp.pl
I must have a prodigious quantity of mind; it takes me as much as a
week sometimes to make it up.
  -- Mark Twain, "The Innocents Abroad"