Re: [AMaViS-user] adding header to mail

2010-01-08 Thread Mark Martinec
Replying to an old thread, with some new information:

On Monday 05 October 2009 20:01:29 Stefan wrote:
  I'm using SpamAssassin with the URICountry Plugin. Now I would like to
  add a X-URI-Country: header to the scanned message. Therefore I added the
  following lines to the URICountry.pm module:
 
# Build a string of all found countries and export it as a tag
my $countries = ;
foreach my $country (keys(%countries)) {
  $countries .= uc($country) . ;
}
chop $countries;
$opts-{permsgstatus}-set_tag(URICOUNTRY, $countries);


package Amavis::Custom;
[...]
sub before_send {
  my($self,$conn,$msginfo) = @_;
  my($uri_country) = $msginfo-supplementary_info('URICOUNTRY');
  if (defined $uri_country  $uri_country ne '') {
  my($hdr_edits) = $msginfo-header_edits;
  my($all_local) = !grep { !$_-recip_is_local }
 @{$msginfo-per_recip_data};
  $hdr_edits-add_header('X-URI-Countries',
$uri_country)  if $all_local;
  }
};
 
  I can use the URICOUNTRY tag with the command 'spamassassin' (e.g. in a
  template like 30_text_de.cf). But amavisd doesn't add a header because
  URICOUNTRY is empty (=). Why doesn't amavisd see the content of
  URICOUNTRY?

 The concept I like to use is the same as with the RelayCountry plugin.
 I guess the problem is that the RelayCountry plugin is collecting its data
 much earlier (in the sub function extract_metadata) as the URICountry
 plugin. The URICountry plugin is collecting its data in the sub function
 parsed_metadata. Both plugins set the tag in the parsed_metadata function.
 But only the RelayCountry plugin can create an additional header (with
 put_metadata) in the extract_metadata function.
 
 So maybe the problem is that the plugin can't create an additional header
 and assign it to the tag. But on the other side is amavisd only evaluating
 the tag and not the header.
 
 So, any ideas why amavisd can not read the content of the tag URICOUNTRY?

The $msginfo-supplementary_info gets filled in a sub call_spamassassin
from a list of 'interesting' tags. You need to add URICOUNTRY to that list:

for my $t (qw(TESTS AUTOLEARN AUTOLEARNSCORE SC SCRULE SCTYPE
  LANGUAGES RELAYCOUNTRY ASN ASNCIDR DCCB DCCR DCCREP
  DKIMDOMAIN DKIMIDENTITY AWLSIGNERMEAN
  CRM114STATUS CRM114SCORE CRM114CACHEID)) {
  $supplementary_info{$t} = $per_msg_status-get_tag($t);
}


With the next release of amavisd, along with SpamAssassin 3.3.0, amavisd
will be able to 'see' added header fields as prepared by SpamAssassin
(through its 'add_header ... _URICOUNTRY_' config option),
and insert them into the mail header section, which will eliminate the
need to collect SA tags and pass them through the supplementary_info
mechanism.

  Mark

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
AMaViS-user mailing list
AMaViS-user@lists.sourceforge.net 
https://lists.sourceforge.net/lists/listinfo/amavis-user 
 AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3 
 AMaViS-HowTos:http://www.amavis.org/howto/ 


Re: [AMaViS-user] adding header to mail

2009-10-05 Thread Stefan
Hello list,

maybe I wasn't clear. So I will try to explain it again.
 
 I'm using SpamAssassin with the URICountry Plugin. Now I would like to add
  a X-URI-Country: header to the scanned message. Therefore I added the
  following lines to the URICountry.pm module:
 
   # Build a string of all found countries and export it as a tag
   my $countries = ;
   foreach my $country (keys(%countries)) {
 $countries .= uc($country) . ;
   }
   chop $countries;
 
   $opts-{permsgstatus}-set_tag (URICOUNTRY, $countries);

I put the whole plugin into the appendix.

 Then I added the following lines to amavisd-custom.conf:
 
   package Amavis::Custom;
   use strict;
 
   sub new {
 my($class,$conn,$msginfo) = @_;
 bless {}, $class;
   }
 
   sub before_send {
 my($self,$conn,$msginfo) = @_;
 my($uri_country) = $msginfo-supplementary_info('URICOUNTRY');
 if (defined $uri_country  $uri_country ne '') {
 my($hdr_edits) = $msginfo-header_edits;
 my($all_local) = !grep { !$_-recip_is_local } @{$msginfo-
 
 per_recip_data};
 
 $hdr_edits-add_header('X-URI-Countries', $uri_country)  if
 $all_local;
 }
 
   };
   1;  # insure a defined return
 
 I can use the URICOUNTRY tag with the command 'spamassassin' (e.g. in a
 template like 30_text_de.cf). But amavisd doesn't add a header because
 URICOUNTRY is empty (=). Why doesn't amavisd see the content of
  URICOUNTRY?

The concept I like to use is the same as with the RelayCountry plugin.
I guess the problem is that the RelayCountry plugin is collecting its data 
much earlier (in the sub function extract_metadata) as the URICountry plugin. 
The URICountry plugin is collecting its data in the sub function 
parsed_metadata. Both plugins set the tag in the parsed_metadata function. But 
only the RelayCountry plugin can create an additional header (with 
put_metadata) in the extract_metadata function.

So maybe the problem is that the plugin can't create an additional header and 
assign it to the tag. But on the other side is amavisd only evaluating the tag 
and not the header. 

So, any ideas why amavisd can not read the content of the tag URICOUNTRY?

 I use: amavisd-new 2.6.2 and SpamAssassin 3.2.5

Thanks for your help.
Greetings
Stefan
--
Come build with us! The BlackBerryreg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9#45;12, 2009. Register now#33;
http://p.sf.net/sfu/devconf___
AMaViS-user mailing list
AMaViS-user@lists.sourceforge.net 
https://lists.sourceforge.net/lists/listinfo/amavis-user 
 AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3 
 AMaViS-HowTos:http://www.amavis.org/howto/ 

Re: [AMaViS-user] adding header to mail

2009-10-03 Thread Benny Pedersen
On fre 02 okt 2009 22:57:03 CEST, Michael Scheidell wrote
 do this in local.cf:
 add_header all Relay-Country _RELAYCOUNTRY_

this only works for spamd, not amavisd

 make sure this is in init.pre:
 loadplugin Mail::SpamAssassin::Plugin::RelayCountry

 use stuff like this in local.cf:

 score RELAY_COUNTRY_KR 5
 score RELAY_COUNTRY_CN 5
 score RELAY_COUNTRY_HK 5

 Then I added the following lines to amavisd-custom.conf:

keep this, here is how i do:

   my($rly_country) = $msginfo-supplementary_info('RELAYCOUNTRY');
   if (defined $rly_country  $rly_country ne '') {
 my($hdr_edits) = $msginfo-header_edits;
 my($all_local) = !grep { !$_-recip_is_local }  
@{$msginfo-per_recip_data};
 $hdr_edits-add_header('X-Relay-Countries', $rly_country) if $all_local;
   }



-- 
xpoint


--
Come build with us! The BlackBerryreg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9#45;12, 2009. Register now#33;
http://p.sf.net/sfu/devconf
___
AMaViS-user mailing list
AMaViS-user@lists.sourceforge.net 
https://lists.sourceforge.net/lists/listinfo/amavis-user 
 AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3 
 AMaViS-HowTos:http://www.amavis.org/howto/ 


[AMaViS-user] adding header to mail

2009-10-02 Thread Stefan
Hello list,

I'm using SpamAssassin with the URICountry Plugin. Now I would like to add a 
X-URI-Country: header to the scanned message. Therefore I added the following 
lines to the URICountry.pm module:

  # Build a string of all found countries and export it as a tag
  my $countries = ;
  foreach my $country (keys(%countries)) {
$countries .= uc($country) . ;
  }
  chop $countries;

  $opts-{permsgstatus}-set_tag (URICOUNTRY, $countries);

Then I added the following lines to amavisd-custom.conf:

  package Amavis::Custom;
  use strict;

  sub new {
my($class,$conn,$msginfo) = @_;
bless {}, $class;
  }

  sub before_send {
my($self,$conn,$msginfo) = @_;
my($uri_country) = $msginfo-supplementary_info('URICOUNTRY');
if (defined $uri_country  $uri_country ne '') {
my($hdr_edits) = $msginfo-header_edits;
my($all_local) = !grep { !$_-recip_is_local } @{$msginfo-
per_recip_data};
$hdr_edits-add_header('X-URI-Countries', $uri_country)  if 
$all_local;
}

  };
  1;  # insure a defined return

I can use the URICOUNTRY tag with the command 'spamassassin' (e.g. in a 
template like 30_text_de.cf). But amavisd doesn't add a header because 
URICOUNTRY is empty (=). Why doesn't amavisd see the content of URICOUNTRY?

I use: amavisd-new 2.6.2 and SpamAssassin 3.2.5

Greetings
Stefan

--
Come build with us! The BlackBerryreg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9#45;12, 2009. Register now#33;
http://p.sf.net/sfu/devconf
___
AMaViS-user mailing list
AMaViS-user@lists.sourceforge.net 
https://lists.sourceforge.net/lists/listinfo/amavis-user 
 AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3 
 AMaViS-HowTos:http://www.amavis.org/howto/ 


Re: [AMaViS-user] adding header to mail

2009-10-02 Thread Michael Scheidell
Stefan wrote:
 Hello list,

 I'm using SpamAssassin with the URICountry Plugin. Now I would like to add a 
 X-URI-Country: header to the scanned message. Therefore I added the following 
 lines to the URICountry.pm module:

   
put your old uricountry.pm back.

do this in local.cf:

add_header all Relay-Country _RELAYCOUNTRY_

make sure this is in init.pre:

loadplugin Mail::SpamAssassin::Plugin::RelayCountry

use stuff like this in local.cf:

score RELAY_COUNTRY_KR 5
score RELAY_COUNTRY_CN 5
score RELAY_COUNTRY_HK 5

   # Build a string of all found countries and export it as a tag
   my $countries = ;
   foreach my $country (keys(%countries)) {
 $countries .= uc($country) . ;
   }
   chop $countries;

   $opts-{permsgstatus}-set_tag (URICOUNTRY, $countries);

 Then I added the following lines to amavisd-custom.conf:

   package Amavis::Custom;
   use strict;

   sub new {
 my($class,$conn,$msginfo) = @_;
 bless {}, $class;
   }

   sub before_send {
 my($self,$conn,$msginfo) = @_;
 my($uri_country) = $msginfo-supplementary_info('URICOUNTRY');
 if (defined $uri_country  $uri_country ne '') {
 my($hdr_edits) = $msginfo-header_edits;
 my($all_local) = !grep { !$_-recip_is_local } @{$msginfo-
   
 per_recip_data};
 
 $hdr_edits-add_header('X-URI-Countries', $uri_country)  if 
 $all_local;
 }

   };
   1;  # insure a defined return

 I can use the URICOUNTRY tag with the command 'spamassassin' (e.g. in a 
 template like 30_text_de.cf). But amavisd doesn't add a header because 
 URICOUNTRY is empty (=). Why doesn't amavisd see the content of URICOUNTRY?

 I use: amavisd-new 2.6.2 and SpamAssassin 3.2.5

 Greetings
 Stefan

 --
 Come build with us! The BlackBerryreg; Developer Conference in SF, CA
 is the only developer event you need to attend this year. Jumpstart your
 developing skills, take BlackBerry mobile applications to market and stay 
 ahead of the curve. Join us from November 9#45;12, 2009. Register now#33;
 http://p.sf.net/sfu/devconf
 ___
 AMaViS-user mailing list
 AMaViS-user@lists.sourceforge.net 
 https://lists.sourceforge.net/lists/listinfo/amavis-user 
  AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3 
  AMaViS-HowTos:http://www.amavis.org/howto/ 
   


_
This email has been scanned and certified safe by SpammerTrap(r). 
For Information please see http://www.spammertrap.com
_
--
Come build with us! The BlackBerryreg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9#45;12, 2009. Register now#33;
http://p.sf.net/sfu/devconf
___
AMaViS-user mailing list
AMaViS-user@lists.sourceforge.net 
https://lists.sourceforge.net/lists/listinfo/amavis-user 
 AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3 
 AMaViS-HowTos:http://www.amavis.org/howto/ 


Re: [AMaViS-user] adding header to mail

2009-10-02 Thread Stefan
On Friday, 2. Oktober 2009 22:57:03 you wrote:
 Stefan wrote:
  Hello list,
 
  I'm using SpamAssassin with the URICountry Plugin. Now I would like to
  add a X-URI-Country: header to the scanned message. Therefore I added the
  following lines to the URICountry.pm module:
 
 put your old uricountry.pm back.
 
 do this in local.cf:
 
 add_header all Relay-Country _RELAYCOUNTRY_

This will not work with amavisd-new, therefore I have to use amavisd-custom.

 make sure this is in init.pre:
 
 loadplugin Mail::SpamAssassin::Plugin::RelayCountry
 
 use stuff like this in local.cf:
 
 score RELAY_COUNTRY_KR 5
 score RELAY_COUNTRY_CN 5
 score RELAY_COUNTRY_HK 5

You mistake RelayCountry for URICountry. See:
http://wiki.apache.org/spamassassin/URICountryPlugin

snip

Greetings
Stefan

--
Come build with us! The BlackBerryreg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9#45;12, 2009. Register now#33;
http://p.sf.net/sfu/devconf
___
AMaViS-user mailing list
AMaViS-user@lists.sourceforge.net 
https://lists.sourceforge.net/lists/listinfo/amavis-user 
 AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3 
 AMaViS-HowTos:http://www.amavis.org/howto/ 


Re: [AMaViS-user] adding header to mail

2009-10-02 Thread Michael Scheidell
Stefan wrote:
 On Friday, 2. Oktober 2009 22:57:03 you wrote:
   
 Stefan wrote:
 
 Hello list,

 I'm using SpamAssassin with the URICountry Plugin. Now I would like to
 add a X-URI-Country: header to the scanned message. Therefore I added the
 following lines to the URICountry.pm module:
   
 put your old uricountry.pm back.

 

ah, idiot me...

didn't look, sorry, open mouth, insert foot.

_
This email has been scanned and certified safe by SpammerTrap(r). 
For Information please see http://www.spammertrap.com
_

--
Come build with us! The BlackBerryreg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9#45;12, 2009. Register now#33;
http://p.sf.net/sfu/devconf
___
AMaViS-user mailing list
AMaViS-user@lists.sourceforge.net 
https://lists.sourceforge.net/lists/listinfo/amavis-user 
 AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3 
 AMaViS-HowTos:http://www.amavis.org/howto/ 


Re: [AMaViS-user] Adding Header

2009-04-16 Thread mouss
Jeff Grossman a écrit :
 I have just started using Postfix along with Amavis and everything
 appears to be running pretty well.  I do have one question, and I am
 not sure if it relates to Amavis or to Postfix.  I was running
 Sendmail with MIMEDefang.  I had my filter in MIMEDefang configured so
 any e-mail that was received for user1 it would add an e-mail header
 called X-Forward: Yes and I send the e-mail to user1 and user2.
 User2 has a Sieve script configured that any e-mail with that header
 would automatically save to a particular folder.
 
 Now, with Postfix, I have it set using recipient_bcc to automatically
 copy any e-mail from user1 to user2.  But, there is no longer that
 header added and I don't know how to automatically filter those
 messages into a particular folder.  Can I add an e-mail header with
 Amavis so I can filter the message?  Or is there something I can do in
 Postfix that will allow me to automatically copy the message and file
 in a particular folder.
 
 I am using Dovecot's Deliver as the LDA.
 

do that in postfix. the simplest way is to use tagged addresses:

you can use address extensions and bcc user2+...@example.com. your LDA
can then look for +...@example.com.


if you don't want extensions, you can create a domain, say
bcc.example.com, and send copies to us...@bcc.example.com.

followup on postfix-users list.

--
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
___
AMaViS-user mailing list
AMaViS-user@lists.sourceforge.net 
https://lists.sourceforge.net/lists/listinfo/amavis-user 
 AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3 
 AMaViS-HowTos:http://www.amavis.org/howto/ 


Re: [AMaViS-user] Adding Header

2009-04-16 Thread Mark Martinec
Jeff,

 I have just started using Postfix along with Amavis and everything
 appears to be running pretty well.  I do have one question, and I am
 not sure if it relates to Amavis or to Postfix.  I was running
 Sendmail with MIMEDefang.  I had my filter in MIMEDefang configured so
 any e-mail that was received for user1 it would add an e-mail header
 called X-Forward: Yes and I send the e-mail to user1 and user2.
 User2 has a Sieve script configured that any e-mail with that header
 would automatically save to a particular folder.

 Now, with Postfix, I have it set using recipient_bcc to automatically
 copy any e-mail from user1 to user2.  But, there is no longer that
 header added and I don't know how to automatically filter those
 messages into a particular folder.  Can I add an e-mail header with
 Amavis so I can filter the message?  Or is there something I can do in
 Postfix that will allow me to automatically copy the message and file
 in a particular folder.

 I am using Dovecot's Deliver as the LDA.

I'd use 'plus addressing', i.e. adding an extension to a recipient
address after a delimiter (usually a '+'), then the LDA can save
a message to a dedicated folder based on that extra string in a
recipient's address.

Something like:

main.cf:
  recipient_delimiter = +

the in alias or .forward or virtual aliases maps:
  user1  user1, user2+us...@example.com
or in recipient_bcc_maps:
  user1  user2+us...@example.com

so a copy of a mail for user1 will also be delivered to user2,
with the envelope recipient address saying 'user2+user1'.

The it us up to a LDA to decide what to do with a '+user1'
extension - by default it is ignored, but can be used to
specify a folder name for example. I know cyrus can do it,
I'm sure Dovecot can do it too.

  Mark


--
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
___
AMaViS-user mailing list
AMaViS-user@lists.sourceforge.net 
https://lists.sourceforge.net/lists/listinfo/amavis-user 
 AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3 
 AMaViS-HowTos:http://www.amavis.org/howto/ 


[AMaViS-user] Adding Header

2009-04-14 Thread Jeff Grossman
I have just started using Postfix along with Amavis and everything
appears to be running pretty well.  I do have one question, and I am
not sure if it relates to Amavis or to Postfix.  I was running
Sendmail with MIMEDefang.  I had my filter in MIMEDefang configured so
any e-mail that was received for user1 it would add an e-mail header
called X-Forward: Yes and I send the e-mail to user1 and user2.
User2 has a Sieve script configured that any e-mail with that header
would automatically save to a particular folder.

Now, with Postfix, I have it set using recipient_bcc to automatically
copy any e-mail from user1 to user2.  But, there is no longer that
header added and I don't know how to automatically filter those
messages into a particular folder.  Can I add an e-mail header with
Amavis so I can filter the message?  Or is there something I can do in
Postfix that will allow me to automatically copy the message and file
in a particular folder.

I am using Dovecot's Deliver as the LDA.

Thanks,
Jeff


--
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
___
AMaViS-user mailing list
AMaViS-user@lists.sourceforge.net 
https://lists.sourceforge.net/lists/listinfo/amavis-user 
 AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3 
 AMaViS-HowTos:http://www.amavis.org/howto/