Domain-wide disclaimers / Signatures, and From:

Discuss your pilot or production implementation with other Zimbra admins or our engineers.
Ace Suares
Posts: 49
Joined: Thu Aug 07, 2014 7:26 pm

Domain-wide disclaimers / Signatures, and From:

Postby Ace Suares » Tue Jul 26, 2016 3:22 am

When u are using domain-wide disclaimers, the disclaimers get chosen by the From: address.

We have a setup where we have various sub domains, but they all need to appear to be from the main domain.

So, mail from a.user@department1.example.com needs to come from a.user@example.com

We do that via this code:

Code: Select all

$ cat SetFromAddress
#!/bin/bash

for i in `zmprov -l gaa department1.example.com`
do
  uid=${i%@*} # extract the part before the @
  echo "aaa $i $uid@example.com # add an alias for a.b@department1.example.com: a.b@example.com
  ma  $i zimbraPrefFromAddress $uid@example.com #set the from: address to a.b@example.com
  ma  $i zimbraPrefFromAddressType sendAs" | zmprov
done


This works well, except that Zimbra will choose the disclaimer for the domain 'example.com' for all addresses, instead of showing the disclaimer for department1.example.com!

Now I know this is a bad hack, my Perl is extremely lousy.

In /opt/zimbra/amavisd/sbin/amavisd, which is a Perl script, I made the following modifications:

Around line 15915:

Code: Select all

              $disclaimer_options = ''  if !defined $disclaimer_options;

              ### give some extra flavor 
              my $disclaimer_domain = $msginfo->sender_smtp;
              $disclaimer_domain =~ s/^<.*@([a-z.-A-Z]+)>$/$1/;
              if ($disclaimer_domain eq "department1.example.com") {
                $disclaimer_options = "department1.example.com";
                }
              else {
                $disclaimer_options = "example.com";
              }         
              ### ace 2016
              s/_OPTION_/$disclaimer_options/gs  for @altermime_args;


What this does, in a quite heinous manner, is looking at the SMTP return address, which seems to be coded as $msginfo->sender_smtp,
and the use a simple if statement to determine which disclaimer should be used.

For every new sub domain, the code has to be rewritten, and Zimbra updates may break this thing. I tried to pass the $disclaimer_domain but some 'tainted' security error popped up.

It would be marvelous if there was an option to specify per domain, what disclaimer should be chosen, but that may lay in the future somewhere.

For now, this seems to work, but I fear that the $msginfo->sender_smtp might not always give a correct value (forwarded messages? mailer daemon stuff?) but for now it holds.

Open for suggestions!


Return to “Administrators”

Who is online

Users browsing this forum: No registered users and 20 guests