Set up Mail Server on Ubuntu

PHP send email setup

http://ph.ubuntuforums.com/showthread.php?t=887081

To install postfix

sudo apt-get install postfix

Intall mailx package for use as command mail utility program. Mail command is installed with this package.

sudo apt-get install mailx

Add a user before you start this.

sudo useradd -m -s /bin/bash fmaster
sudo passwd fmaster

Test your default installation using the following code segment.

telnet localhost 25

Postfix will prompt like following in the terminal so that you can use to type SMTP commands.

Trying 127.0.0.1...
Connected to mail.fossedu.org.
Escape character is '^]'.
220 localhost.localdomain ESMTP Postfix (Ubuntu)

Type the following code segment in Postfix's prompt.

ehlo localhost
mail from: root@anywher.com
rcpt to: support@localhost
data
Subject: My first mail on Postfix

Hi,
Are you there?
Regards,
Admin
.(Type the .[dot] in a new Line and press Enter )
quit

Check the mailbox of support

su - support (change user to support after login to the host)
mail
Setting Postfix support for Maildir-style mailboxes

GUI -
https://help.ubuntu.com/community/Postfix
Manually

Maildir is a format for an e-mail spool that does not require file locking to maintain message integrity because the messages are kept in separate files with unique names. A Maildir is a directory (often named Maildir) with three subdirectories named tmp, new, and cur. The subdirectories should all reside on the same filesystem.

Another reason to use Maildir format is that Courier IMAP/POP3 servers only work with Maildir format of mailboxes.

Please find out more about Maildir here

Instruct Postfix to use Maildirs instead of Mboxes:

sudo postconf -e "home_mailbox = Maildir/"

Ensure Procmail isn't used: (if the step was taken during dpkg-reconfigure, by mistake)

sudo postconf -e "mailbox_command = "

Restart Postfix to make changes effect.

sudo  /etc/init.d/postfix restart
Test your setup again

Installing courier IMAP and POP3
sudo apt-get install courier-pop
sudo apt-get install courier-imap

Adding your local domains to postfix

Add your domains to mydestination:

sudo postconf -e "mydestination = mail.thecoolmeter.com, localhost.localdomain, localhost, thecoolmeter.com"

Add your local networks, too:

Postfix comes with the localhost (127.0.0.1) entry; you may have others, here we assume your LAN is on 192.168.1.0/24. Make changes to suit your situation.

sudo postconf -e "mynetworks = 127.0.0.0/8, 192.168.1.0/24"

Make Postfix to receive mail from the Internet

Instruct Postfix to receive on all interfaces:

sudo postconf -e "inet_interfaces = all"

(optional) Make Postfix accept IPv4, IPv6 protocols

If you're not using IPv6 yet, and you're paranoid, use "ipv4" instead of "all". Again, this is to suit your own network sensibilities.

sudo postconf -e "inet_protocols = all"

Finally, restart Postfix;

sudo  /etc/init.d/postfix restart

Test your setup again using following code:

telnet mail.yourdomain.com 25 ehlo yourdomain.com mail from: root@yourdomain.com rcpt to: fmaster@yourdomain.com data Subject: My first mail for my domain  Hi, Are you there? regards, Admin . (and Enter In a new Line) quit

Check the mailbox of fmaster

su - fmaster
cd Maildir/new
ls

Testing Courier POP3

Type in a terminal:

telnet mail.yourdomain.com 110

Use the following example code segment for your test. Be intelligent to tweak the changes appropriately to your environment. An output like follows will display in your terminal.

Connected to mail.yourdomain.com (208.77.188.166). Escape character is '^]'. +OK Hello there.

Type the following code segment in the prompt provided by the Courier POP3 server. I assume that you are intelligent enough not to type the lines which starts from +OK

user fmaster +OK Password required. pass password +OK logged in. quit

Testing Courier IMAP

Type in a terminal:

telnet mail.yourdomain.com 143

Use the following example code segment for your test. Be intelligent to tweak the changes appropriately to your environment. An output like follows will display in your terminal.

* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE ACL ACL2=UNION STARTTLS XCOURIEROUTBOX=INBOX.Outbox] Courier-IMAP ready. Copyright 1998-2005 Double Precision, Inc.  See COPYING for distribution information.

Type the following code segment in the prompt provided by the Courier IMAP server.

a login fmaster password a OK LOGIN Ok. a logout

User email anywhere to access the mail

Comments

Popular posts from this blog

Linking verb - seem, sound, smell, appear, become, get, feel (Verb of Senses)

Phrasal Verb (กิริยาวลี) ที่ใช้บ่อย

If Clause 3 แบบ (Conditional Statement)