Hacking amavisd $msginfo

Alex mysqlstudent at gmail.com
Tue Jun 21 19:18:59 CEST 2011


>> I'm trying to modify amavisd-new-2.6.4 to write specific headers to
>> syslog when a spam is found, and I believe utilizing the $msginfo
>> header in mail_to_local_mailbox is the proper way to do this. This
>> function appears to have all the information about the spam message,
>> including the quarantined file's name.
>> I'm somewhat of a beginning perl programmer, so I'm really not sure
>> how to do this. How can I access the individual elements of the
>> $msginfo structure? Where are they defined?
> As Sahil Tandon noted, it's probably best to start with
> example code in amavisd-custom.conf. The custom hooks
> are also probably a better place for your code than having
> to modify the mail_to_local_mailbox().
>> How can I access the individual elements of the
>> $msginfo structure? Where are they defined?
> See modules Amavis::In::Message and Amavis::In::Message::PerRecip.
> The Amavis::In::Message carries all the methods applicable to
> $msginfo.
> For example:
> $msginfo->sender   is a mail envelope sender address
> $msginfo->msg_size  is a mail size
> $msginfo->spam_level  is a spam score
> $msginfo->per_recip_data  is a ref to a list of recipient objects

Thanks so much. I was experimenting with amavisd-custom.conf before
receiving your email, and your comments here filled in the remaining
questions I had.

I was thinking the amavisd-custom was parsed as a config file, not
something that would support all of perl. I managed to hook the
$msginfo struct to log the info to a bdb to create a quarantine
database. This database is now synced from all the servers and can be
queried to determine where a false positive is located and resent to
the recipient.

Not too bad for a complete perl noob :-)

Thanks again,

More information about the amavis-users mailing list