You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spamassassin.apache.org by Alban Deniz <al...@baker-research.com> on 2009/04/09 16:48:39 UTC

How can a plugin add message-specific headers to an email?

Hello,

I'm developing a plugin, and need to add message-specific headers to the
email.  Because the headers are different for each message, adding a
"add_header" line in the .cf file isn't what I need.

I did find the put_metadata method, but invoking it in
Mail::SpamAssassin::Plugin::extract_metadata() didn't work.  Here's the
code:

        sub extract_metadata {
        
         my ($self, $opts) = @_;
        
         $opts->{msg}->put_metadata("X-Extract-Metadata", "Test
        header");
        
        }

I was hoping to see the header "X-Extract-Metadata: Test header" in the
email, but that didn't happen.

Is there any way to make that happen?  I looked over the documentation,
other plugins, and developer email lists, but didn't find an answer.
I'd appreciate any help (suggestions, references, etc).

I tried this using the spamassassin command line using SA 3.2 on Fedora
7, and also SA 3.2.4 on Ubuntu 8.0.4.

Thanks,
Alban


Re: How can a plugin add message-specific headers to an email?

Posted by Theo Van Dinter <fe...@apache.org>.
Plugins can't directly add headers to the message rewrite process.
However, the plugin can create a tag which you can setup to be added
w/ add_header.

ie:

$permsgstatus->{tag_data}->{FOO} = "foo";

then

add_header all Foo _FOO_

will add X-Spam-Foo to all mails.


On Thu, Apr 9, 2009 at 10:48 AM, Alban Deniz
<al...@baker-research.com> wrote:
> I'm developing a plugin, and need to add message-specific headers to the
> email.  Because the headers are different for each message, adding a
> "add_header" line in the .cf file isn't what I need.
>
> I did find the put_metadata method, but invoking it in
> Mail::SpamAssassin::Plugin::extract_metadata() didn't work.  Here's the
> code:
>
>        sub extract_metadata {
>
>         my ($self, $opts) = @_;
>
>         $opts->{msg}->put_metadata("X-Extract-Metadata", "Test
>        header");
>
>        }
>
> I was hoping to see the header "X-Extract-Metadata: Test header" in the
> email, but that didn't happen.
>
> Is there any way to make that happen?  I looked over the documentation,
> other plugins, and developer email lists, but didn't find an answer.
> I'd appreciate any help (suggestions, references, etc).
>
> I tried this using the spamassassin command line using SA 3.2 on Fedora
> 7, and also SA 3.2.4 on Ubuntu 8.0.4.
>
> Thanks,
> Alban
>
>