[Mimedefang] Autoresponse to old domain

Jason Englander jason at englanders.cc
Thu Apr 3 12:36:01 EST 2003


On Thu, 3 Apr 2003, Shawn Button wrote:

> new.domain.com). Is there a way to set up an auto responder that
> whenever a mail is sent to old.domain.com it is delivered but a response
> is sent to the sender stating something like, "thanks for contacting
> old.domain.com. Your message has been delivered but please note our new
> e-mail domain is new.domain.com."

There are many, many, many different ways of doing that.  You could do it
with vacation (vacation is distributed with sendmail), you could do it
with procmail, you could do it with Sieve (if you run Cyrus IMAP), an
alias that runs a script, ...it all depends on what you use.

The .REDIRECT aliases mentioned are a sendmail feature.  See the
sendmail docs like cf/README, etc. for more about that.

You should not send autoresponder replies to mail addressed
to MAILER-DAEMON@, postmaster@, abuse@, or mailing lists (unless you want
to piss off hundreds of people at once)... so be very careful there.

To do it with MIMEDefang you could do something like this:

  my $to_olddomain = 0;
  foreach my $recip (@Recipients) {
    next if $recip =~ /^(abuse|postmaster|MAILER-DAEMON)@/i;
    if ($recip =~ /old\.domain\.com$/) {
      $to_olddomain = 1;
      last;
    }
  }
  $to_olddomain = 0 if $Sender =~ /^<?linux-kernel-owner.*\@vger\.kernel\.org>?$/i;
  $to_olddomain = 0 if $Sender =~ /^<?mimedefang-admin\@lists\.roaringpenguin\.com>?$/i;
  if ($to_olddomain) {
    open (SENDMAIL,"| /usr/sbin/sendmail -t");
    print SENDMAIL "From: $AdminAddress\n";
    print SENDMAIL "To: $Sender\n";
    print SENDMAIL "Subject: Re: $Subject\n\n";
    print SENDMAIL "thanks for contacting old.domain.com. Your message has been delivered but please note our new e-mail domain is new.domain.com.\n\n";
    close SENDMAIL;
  }

Just make sure you do it in filter_begin() or filter_end().  If you do it
in filter(), it'll e-mail the sender once per attachment.  You should
probably also use something like File::Cache to makes sure that you
don't e-mail a particular sender too frequently.

  Jason

-- 
Jason Englander <jason at englanders.cc>
394F 7E02 C105 7268 777A  3F5A 0AC0 C618 0675 80CA




More information about the MIMEDefang mailing list