Configure the exim4 mail server.

create a directory virtual in the /etc/exim4 open the virtual directory and create a file for each virtual domain with domain names:

touch  example.com
touch  example.net
Add the users for each domain in their file:
khalid  :  khalid@localhost
ahmad  :  hameed@localhost
*  :  khalid@localhost
The mails coming for the user khalid will go to the khalid mail box (khalid@localhost), the mails coming for the user ahmad will go to the other user hameed mail box (hameed@localhost), the last line is a catch all mail, will go to the user khalid mail box.
Care for the line orders, because exim4 reads the lines in the written order.
Opne the /etc/exim4/conf.d/router and create a file 350_exim4-config_vdom_aliases:
#####################################################
### router/350_exim4-config_vdom_aliases
#####################################################

vdom_aliases:
debug_print = "R: vdom_aliases for $local_part@$domain"
driver = redirect
allow_defer
allow_fail
domains = dsearch;/etc/exim4/virtual
data = ${expand:${lookup{$local_part}lsearch{/etc/exim4/virtual/$domain}}}
retry_use_local_part
pipe_transport = address_pipe
file_transport = address_file

vdom_aliases_suffix:
debug_print = "R: vdom_aliases_suffix for $local_part@$domain"
driver = redirect
local_part_suffix = +*
local_part_suffix_optional
allow_defer
allow_fail
domains = dsearch;/etc/exim4/virtual
data = ${expand:${lookup{$local_part}lsearch*@{/etc/exim4/virtual/$domain}}}
retry_use_local_part
pipe_transport = address_pipe
file_transport = address_file
no_more

#####################################################
### end router/350_exim4-config_vdom_aliases
#####################################################
Restart the exim4.
Test your mail server with the command:
telnet localhost 25
telnet example.com 25
If want to add the other smtp port for exim4 to listen like 2525 , open the /etc/default/exim4 and add as:

# options for daemon listening on port 25 and port 2525
SMTPLISTENEROPTIONS='-oX 2525:25'
substitute SMTP ports
These are smpt ports one can try for isp if they let them to send mail:
25, 2525, 8025, 587 and 465 for ssl
Test the exim4:
A very handy trick to see what exim4 is doing with an email address is to run:
exim4 -d -bt user_name@your_domain.com


<< Previous Next >>