Creating a Mail Server on Ubuntu (Postfix, Courier, SSL/TLS, SpamAssassin, ClamAV, Amavis)

  • mail.example.com
    The hostname for your mail server. This can be anything you like, however, it should match the public hostname as specified by your DNS records if you want to expose the server over the Internet.
  • rootpassword
    The password for the MySQL root user. You should pick something unique and secure; but something you can remember.
  • mailpassword
    The password for the MySQL mail user. You should pick something unique and secure; you don’t even have to remember it beyond this tutorial.
  • adminpassword
    The password for the administrator e-mail account that you’ll create later in the guide.

Installation

Enter rootpassword.

Enter rootpassword.

Choose Ok.

Choose No.

Choose Ok.

Choose Internet Site.

Choose Ok.

Enter mail.example.com.

Choose Ok.

Virtual User

Note: All e-mail messages will be received by a single ‘virtual’ user. That is, only one system account needs to be created and we’ll manage mailboxes using the virtual user features of Postfix.

Note that we are forcing the user ID to 5000 as this value is referenced by configuration files later. If you need to use a different UID make sure you update the affected configuration files, too.

Postfix

Copy/paste:
Replace mail.example.com

Copy/paste:

Virtual Maps

Copy/paste:
Replace mailpassword

Copy/paste:
Replace mailpassword

Copy/paste:
Replace mailpassword

SASL Authentication (SSL/TLS)

Copy/paste:
Replace mailpassword

Copy/paste:

Copy/paste:
Replace mailpassword

Courier

Copy/paste:

Copy/paste:
Replace mailpassword

Copy/paste:

Copy/paste:
Replace mail.example.com

Copy/paste:

Copy/paste:
Replace mail.example.com

Note: In the next step you will be prompted to input some information about the certificate you create. You can enter any information you want here except Common Name (CN) which must match mail.example.com.

Amavis

Copy/paste:

SpamAssassin

Copy/paste:

ClamAV

Choose Ok.

Choose daemon.

Choose Ok.

Choose a mirror closest to your server.

Specify a proxy, if required.

Enter 24.

Choose No.

MySQL Database

Enter rootpassword.

Copy/paste:
Replace mailpassword

Create default data. This will:

  • Permit messages sent to the localhost domain
  • Permit messages sent to the localhost.localdomain domain
  • Permit messages sent to the example.com domain
  • Create a mailbox for admin@example.com with the password adminpassword
  • Forward messages to the localhost.localdomain domain to the localhost domain
  • Forward messages to the localhost domain to admin@example.com

Copy/paste:
Replace example.com and adminpassword

Finishing Up

Reboot Services

Create Your Mail Directory

You will not be able to login to your mailbox(es) until you create the required folder structure. There are two ways to do this:

  1. Send an e-mail to your new e-mail address from an existing e-mail account. Postfix will create the required directories for you.
  2. Create the directories yourself: