Brian Schang wrote:
Hello:

I have read through the Postfix documentation and have Googled for an an answer, but I have not found a solution for the following problem...

In a nutshell, I have a number of virtual_mailbox_domains and virtual_mailbox_maps and everything is working perfectly. Now for a given virtual user, I'd like to change the virtual mailbox being used if the message is over a given size.

For instance, assume that I have the following entry in virtual_mailbox_maps:
Mark Martinec was kind enough to translate my C message size filter into perl 
for amavisd-new. You can use it to add:

X-ActualMessageSize: ****** X-ActualMessageSizeBytes: nnnnnn headers to your message (Each "*" = 1MB) then do something with it in header_checks.
I'm not sure how you would use this to redirect it to a different mailbox for 
each user, but it's currently in production HOLDing messages that are too large 
for a client's exchange server.

Terry

-----------------------------------------------------------

Mark's message follows:

If all you need to do is to add two header fields based on mail size,
the simplest way is to call add_header() from a custom hook, e.g.:


somewhere in amavisd.conf add:

 include_config_files('/etc/amavisd-custom.conf');


then in /etc/amavisd-custom.conf :


package Amavis::Custom;
use strict;

# invoked at child process creation time;
# return an object, or just undef when custom checks are not needed
sub new {
 my($class,$conn,$msginfo) = @_;
 my($self) = bless {}, $class;
 my($mail_size) = $msginfo->msg_size;   # mail size in bytes
 my($mail_size_mb) = $mail_size/(1024*1024);
 my($hdr_edits) = $msginfo->header_edits;
 $hdr_edits->add_header('X-ActualMessageSizeBytes', $mail_size);
 $hdr_edits->add_header('X-ActualMessageSize',
                        '*' x ($mail_size_mb > 50 ? 50 : $mail_size_mb));
 $self;  # returning an object activates further callbacks,
         # returning undef disables them
}
1;  # insure a defined return


Reply via email to