Wednesday, September 16, 2009

SENDMAIL Notes 5: Sendmail - Aliases


    Aliases is used to handle mails to a non existing address. This will allow to redirect the msgs destined to a given name to a real user.
eg:-

postmaster: kiran@domain.com,jrkiran@domain.com

    So when a mail comes in sendmail will check the aliases db for the aliases defined for new msgs, and according to the aliases defined sendmail attempts to deliver the msgs to the delivery agent by adding or modifying the headers of the msg with aliases defined in aliase db.

The Aliases File:
Default Aliases in system:


MAILER-DAEMON:  postmaster
postmaster:    root

When a msg is bounced or problem delivering a msg the destination of the msg will be MAILER-DAEMON.
i.e, if a mail is send to a non existing user then the mail header is modified to MAILER-DAEMON as user.
This means the problem msg or bounced msg has to go some where, and sendmail delivers it to MAILER-DAEMON.
MAILER-DAEMON is aliased to postmaster, and postmaster aliased to root - hence the mail is delivered to root.

Aliases File is case insensitive:
The aliases defined in sendmail is case insensitive.
After changing the aliases no need to restart or reload the sendmail  service because in each and every request sendmail consults the db of aliases.

Types of aliases defined

There are 5 types of aliases:

1. 1-to-1 Aliases.(1 alias map to one local username)
eg:-

postmaster:    root
bin:    root
support:    kiran

    2. 1-to-many or 1-to-lists
eg:-

info:    kiran,jithu,rinz
sales:    hr,joe,nick

    3. using include directive in aliases file.
This will allow aliases to include the list from separate file
eg:-

finance:    :include:/full/path/to/list.list

"users or mail address in the list file can be separated by comma."
    4. File Redirection Aliases - Re-route the message to file
eg:-

abuse:    root,/var/log/abuse/mail
help:    /var/log/help

    All mail send to the user abuse will be re - routed in to /var/log/abuse/mail. This will help to collect the evidences of mail that is routed for given aliases. The file should not have the execute permission. Else sendmail will fail to write to this file
5.Redirecting the E-mail to PIPE (redirecting the output to an application)
    when a mail comes we can send the output to certain commands. for example if mail comes for the user john and the is in vacation then we can redirect the mail to the program "vacation" to send the automated reply.
eg:-

kiran:    "|/usr/bin/vacation kiran"

Creating a aliases
Add entry

#vim /etc/mail/aliase
support:    kiran

Update db

#newaliases

Test the aliase file

#sendmail -bi

Test the aliase

# sendmail -bv support
kiran... deliverable: mailer local, user kiran

    This means aliases support is deliverable, and it uses mailer local, and user who ultimately get msg.

Vacation Program
To enable the vacation program for an user called fazi install the vacation program that comes along with the sendmail binary.

Create a forward file

# vim ~/.forward
\fazi, "|/usr/bin/vacation -t0 fazi"

Now create the msg that needed to be auto reply.

# vim ~/.vacation.msg
Hi Thanks for you mail !
hai i am on vacation
will ping you once i'm back

This will invoke an automated reply to the sender including the msg body from the file .vacation.msg.

No comments:

Post a Comment

tag ur valuable ideas below