Selasa, 10 Juni 2014

Creating an alias for an account

The following codes illustrate how you can setup an alias. This step is optional since we are going to configure virtual mail domains later in this howto. I have added this step to make sure you understand how you can do this in case it is required.
Create a user
sudo useradd -m -s /bin/bash sysadmin
sudo passwd sysadmin
Edit the alias table
Open the alias file with:
sudo vi /etc/aliases
Add the following code:
fmaster: sysadmin
To make your changes take effect type:
sudo newaliases

To test your changes send a mail to fmaster and check the mail in /home/sysadmin/Maildir/new folder.

Per User .forward Files

Users can control their own mail delivery by specifying destinations in a file called .forward in their home directories. The syntax of these files is the same as system aliases, except that the lookup key and colon are not present.
I will illustrate an example here:
Assume that you need to forward all the mails which come to the sysadmin account to an another account. Enter the following commands:
su - sysadmin
touch .forward
Then open the .forward file
vi .forward
Add the following code:
fossedu@example.com
Remember to use email address which exists in this exercise.

Now send a mail to sysadmin and mail should come to fossedu@example.com
With this approach, every hosted domain can have its own info etc. email address. However, it still uses Linux system accounts for local mailbox deliveries.
With virtual alias domains, each hosted address is aliased to a local UNIX system account or to a remote address. The example below shows how to use this mechanism for the fossedu.org and linuxelabs.com domains.
Inside the main.cf file, we tell it how to handle these virtual domains:
sudo postconf -e "virtual_alias_domains = fossedu.org linuxelabs.com"
sudo postconf -e "virtual_alias_maps = hash:/etc/postfix/virtual"
Edit the /etc/postfix/virtual file:
Add two Linux system accounts
sudo useradd -m -s /bin/bash sigiri
sudo useradd -m -s /bin/bash kala
Set passwords for the above users.
sudo passwd sigiri
sudo passwd kala
sudo vi /etc/postfix/virtual
Add the following code segment:
info@fossedu.org       sigiri
info@linuxelabs.com    kala
To create a Map Database type :
sudo postmap /etc/postfix/virtual
postmap is utility program that will convert /etc/postfix/virtual to /etc/postfix/virtual.db in Berkley DB format, so that Postfix can access the data faster.
Restart Postfix to make changes take effect:
sudo /etc/init.d/postfix restart

Send mails to both info@fossedu.org and info@linuxelabs.com and those mails should come to mailboxes of sigiri and kalarespectively.