Saturday, December 21, 2013

Postfic Configuration on Ubuntu 12.04


Postfix Intallation:

1. $ sudo apt-get install postfix

Make sure you select follow option while installing the Postfix


2. $ service postfix restart
3. $ ls -l /etc/postfix
4. $ netstat -nat | grep 25 -------------------------------- To check listing ports

$ sudo dpkg-reconfigure postfix ------------------------------ re edit the postfix installation
$ sudo /etc/init.d/postfix restart --------------------------------- postfix restart




Postfix Configuration:

#### to edit postfix file ####
1. $ sudo nano /etc/postfix/main.cf
myhostname = mail_server.ciscokeshara.com --------------------------------------- this is the mail server name
mydomain = ciscokeshara.com ------------------------------------------------------------- specify the mailserver domain
mydestination = $myhostname, $mydomain, localhsot, test.com, ------------------here specify all Domains and Hosts for which our postfix accept local delivery.
mynetworks = 127.0.0.0/8 192.168.6.0/24
mynetworks_style = subnet
myorigin = ciscokeshara.com ----------------------------------------- specifies the domain that appears in mail that is posted on this machine. This is some kind of Masquarading where it modify the out going mail's header.
inet_interfaces = all --------------------------------------- this mean, by defult, postfix listen on port 25/TCP on all ip address
inet_protocols = all ---------------------------------------------------------------- enable ipv4 and ipv6, if enabled
# masquerade_exceptions = root ----------------------------------------- !!!! Optional !!! - this will cause not to modify the outgoing mail's header
home_mailbox = Maildir/ --------------------------------------------------------- specify home mail box where mail will be saved

-Optional- $ always_bcc = address ------------------------------------------------------ if we want write all massages in the main configuration file


Postfix testing:

$ telnet localhost 25
$ ehlo localhost
$ mail from: root@ciscokeshara.com
$ rcpt to: kesh@ciscokeshara.com
$ data
$ <enter the massage you wan to send>
$ .


To add a user:
$ sudo useradd -m -s /bin/bash <username>
$ sudo passwd <username>

To check send mail:
  • go to the user account by ---------------- $ su - <username>
  • and simply type --------------------------- $ "mail"