Mail server - Postfix and MySQL installation

Now we've configured the base Slice details and added the vmail user, we are ready to install Postfix and MySQL.

Remember, we will be using MySQL to control the domains and user details for our mail server.


Installation

As well has installing postfix and the relevant MySQL packages, we'll also install telnet and mailx. These two packages will allow us to test the installation at different stages of the mail server setup.

let's go ahead and do that:

sudo aptitude install postfix postfix-mysql mysql-server postfix-tls libsasl2-2 libsasl2-modules libsasl2-modules-sql sasl2-bin libpam-mysql openssl telnet mailx

As the base Slices are minimal Linux images, quite a few packages will be installed.

You will be asked some questions during the installation.

Firstly, you will need to set the root password for MySQL:

Set the MySQL root password

Once done, you will be asked to repeat the password.

Next is the postfix installation.

The first screen is informative and you can simply press Enter/Return on the keyboard.

Next select 'Internet Site' and press Enter/Return:

Postfix - Internet Site option

The next screen asks for the system mail name:

Postfix - setting the system mail name

Enter the same name as set in the previous article. In this case, I entered 'mail.demoslice.com'.

Test

The base Postfix and MySQL installation is now complete.

You can test the Postfix installation by sending a quick email from the Slice to a working email address.

From the terminal:

mail address@example.com

Note you will need to replace the 'address@example.com' with a working email address - your usual email address will suffice.

You will need to enter the subject and body of the email. Once done press Enter/Return and enter a single period (.) - this lets the mail command know the message has finished.

You will need to press Enter/Return a couple more times to send the mail. Once done you will be placed back at the command prompt.

This is what my terminal looked like during the test:

mail adress@example.com 
Subject: test email from demoslice.com
test body of email
.
Cc:

A few seconds later I had a new and shiny email from my Slice. Note that at this stage the 'from' field was shown to be:

demo@mail.demoslice.com

The next articles will show how to set the correct domain in the 'from' field.

Summary

The base Postfix and MySQL installation is very simple and the Slice is already set to send emails.

The next article will look at creating the mail database in MySQL for multiple domains and users.

PickledOnion

Article Comments:

Luke commented Sun Dec 07 05:18:58 UTC 2008:

Hi. I wend through the complete tutorial and when testing it didn't work, so know I'm going through it all again and I noticed that the mail command isn't working anymore. It did work the first time I wend through the tutorial through. What would be the point to start trouble shooting this?

Will commented Sat Jan 31 15:36:00 UTC 2009:

Hi, it appears that I may have done something sort of dumb. I followed your instructions, but I set the mail name in the postfix configuration to "example.com" (not really example.com, but another one), instead of "mail.example.com". Will that affect anything? I was able to send a test email by the way.

Daniel Codrea commented Mon Mar 23 08:31:31 UTC 2009:

Hi, I followed the examples in the article step by step, I used a mail command , but nothing happened. No error, but no mail either. Can you assist please? Daniel

Patrick Sanchez commented Mon Mar 23 10:50:25 UTC 2009:

I can't send mail also. After typing the subject, my console seems to hang.

Hexstream commented Wed Apr 29 14:18:29 UTC 2009:

After you've entered the subject, the mail command is simply waiting for the body of the message. Type it in, then input a dot alone on one line when you're done. That is, press Enter, ".", Enter.

chovy commented Fri May 15 04:11:58 UTC 2009:

How do I re-define the options when running the initial sudo apt-get install ... command?

ie: if i want to change my mail server domain in postfix et.al

Mauro commented Sun Jul 12 22:39:11 UTC 2009:

The postfix configuration hangs on Ubuntu 9.04. It simply does not accept any input and freezes. The only way out is to kill terminal.

csurlee commented Fri Jul 31 10:55:46 UTC 2009:

i have some problems with my postfix or courier server

i cannot connect to the IMAP server with SquirrelMail, the message i get is "ERROR: Connection dropped by IMAP server." i have created the users i sent the first message.

i think i have everything UP and working properly, but still its not working

i found something in the mail.err log file:

Code:

Jul 31 12:47:13 revistafirme imapd: authentication error: Input/output error Jul 31 12:48:31 revistafirme pop3d: authentication error: Input/output error Jul 31 12:49:02 revistafirme last message repeated 10 times Jul 31 12:49:17 revistafirme last message repeated 7 times Jul 31 12:59:24 revistafirme imapd: authentication error: Input/output error Jul 31 12:59:32 revistafirme imapd: authentication error: Input/output error Jul 31 13:17:11 revistafirme pop3d: authentication error: Input/output error

thanks

best regards.

James C commented Fri Aug 28 19:43:44 UTC 2009:

When installing Postfix, Sendmail is removed. No surprise there, however at boot time, Sendmail still tries to start. How do I prevent this?

James C commented Fri Aug 28 19:55:34 UTC 2009:

Okay, I found a workaround, but I've a feeling there's a better way. For those interested:

sudo chkconfig sendmail off

spud commented Tue Jan 12 17:46:28 UTC 2010:

Just a quick note -- after this setup, I sent a test message to my other mail server, which uses the Spamhaus RBL (zen.spamhaus.org) to combat spam.

It is worth noting that the entire 204.232.200.0/21 IP range (which includes my slice) is blacklisted by the Policy Block List (PBL), so mail from your slice will instantly be rejected by any mail using the Spamhaus RBL. You can remove your IP from the PBL here.

jday commented Fri Jun 11 06:25:52 UTC 2010:

when I get to the test part of the tutorial I get this error: -bash: mail: command not found

I had postfix configured and working on a Hardy set up then I upgraded to Lucid and now email does not work anymore.

Jered commented Fri Jun 11 18:12:53 UTC 2010:

You'll need to install a package that contains the mail command, it sounds like - that command may have been lost in the shuffle. Try "sudo aptitude install mailutils", and that should do the trick.

cloudtech commented Fri Jul 30 22:40:00 UTC 2010:

Hi jday,

Have you installed mailx? I have the same problem and it was fixed by this command.

sudo aptitude install mailx

Centos:

yum install mailx

Dustin commented Thu Sep 02 06:24:58 UTC 2010:

If typing a single '.' and pressing Enter does not send your test email, try inserting an "End-of-file" character by pressing 'Ctrl-D'.

Want to comment?


(not made public)

(optional)

(use plain text or Markdown syntax)