Sendmail use this file to "alias" email to users, groups, script files or even Mailmanagers.
With a standard Linux installation, this file is for some reason located in the /etc directory and not in the /etc/mail directory like the rest of the email configuration files.
I believe it is best to keep all the email configuration files in one directory, so I suggest you MOVE the /etc/aliases and the /etc/aliases.db files into the /etc/mail directory. Once you have done this, you MUST edit the /etc/mail/sendmail.cf file and change the location where sedmail is looking for the alias file. so you need to edit /etc/mail/sedmail.cf and look for the line:
" O AliasFile=/etc/aliases "
Change this line to read the following:
"O AliasFile=/etc/mail/aliases"
Write and quit the file, and again do a " service sendmail reload " or just run that sendmailreload script I have posted previously.
Lets look at the contents and the uses for the aliases file.
Option 1:
If you need to forward mail to more than one mailbox, example is sales, then you would use the aliases file. Inside the virtusertable file, you will state that sales@lds.za.net goes to user account lin001.
Then in the aliases file, you will have the following line to forward the mail to 4 other users as well, even external mail account, the following is the exact line:
lin001: user1, user2, user3, bill@gates.com
or
sales@lds.za.net: user1, user2, user3, bill@gates.com
Option 2:
If you need to forward mail for a specific user to himself and someone else, because he is on leave, then you would do the following.
jdoe@lds.za.net: \jdoe, user2
The \ in front of the username prevents the mail from looping that that user. Since the virtusertable already relay the mail to that user, you will create a loop of mail to that user by sending it to them again in the alias file.
Option 3:
You need to run a script file when someone sends an email to your server, almost like list managers, but normally used to send someone a legal disclaimer or something. The following line in the aliases file must be used.
disclaimer@lds.za.net: /path/to/script/file
Option 4:
The MD is going oversee on a business trip, and wants his email forwarded somewhere else, or to the branch where he is going, do the following.
ltrovald@lds.za.net: ltrovald@usa.lds.za.net
This will forward all mail to another mail address as specified.
Option 5:
The MD wants his mail to be kept on the server AND sent to the other email address as well, then do the following:
ltrovald@lds.za.net: \ltrovald, ltrovald@usa.lds.za.net
Remember to write a quit the /etc/mail/aliases file, and run the following command before reloading sendmail
makemap hash /etc/mail/aliases.db < /etc/mail/access
service sendmail reload
That is it, please post comments if you need more help.
1 comment:
I want to have 1000s of alias email and its depend on the program i have, also I would like to add or remove alias. Each alias will need to forwarded to its real email id
I am not able to find any concrete solution.
I need a way to add it through
linux
or
include a file which will have all alias and manage it from php
or
i can access all mail from php code and then send it to real address
Thanks in Advance
Post a Comment