I am a danish programmer living in Bangkok.
Read more about me @ rasmus.rummel.dk.
Webmodelling Home > Downloads > Create Email Server - Download Script

Create Email Server - Download Script

Updated 01 Mar 2013 You want a full fledged email server and you want to use Ubuntu - this is it.

createemailserver.sh is a shell script that can create a full fledged ready to use production email server from scratch on a fresh Ubuntu server. Currently only tested on Ubuntu 11.10 (Oneiric)

  • Script name : createemailserver.sh
  • Script version : 1.1 (bug update)
  • Environment : Ubuntu bash shell
  • Function : creates an email server
    • option 1 : create a full fledged email server from scratch.
    • option 2 : enhance a lamp stack with an email server (nearly the same as option 1).
    • option 3 : select individually parts of the script and execute them step-by-step.

createemailserver.sh was created as a support or an alternative to my Ubuntu email server tutorial - even if you buy this script, you may still benefit from taking a look at the tutorial.

createemailserver.sh cost US$5. Then you have payed, you will get a download link in your email, this link will be available for 10 days.

Prepare executing the script :

  1. Copy createemailserver.sh to some folder on your Ubuntu machine.
  2. shell> su root : switch to root if you are not already root.
  3. shell> chown root:root createemailserver.sh : change owner & group to root.
  4. shell> chmod 700 createemailserver.sh : this is to make the script executable and accessible by root only.
  5. shell> ./createemailserver.sh : execute the script.

Executing the script - depending on what option (1-3) you select, you will be prompted along the way :

  1. MySQL root user name : normally root.
  2. MySQL root user password : whatever.
  3. Postfix system mail name : your internet domain on which you want to receive email, eg. if your want say this address : rasmus@webmodelling.com, then Postfix system mail name should webmodleling.com.
  4. Password for Postfix MailAdmin user : whatever.
  5. Your servers fully qualified domain name : eg. mail.example.tld. If your sever is correctly configured, the script will correctly guess it.
  6. Your servers internet domain name : eg. example.tld. If your server is correctly configured, the script will correctly guess it.
  7. Passphrase for private key generation : whatever.
  8. Different info for Certificate Signing Request : you don't need to answer all CSR questions, however common name value must be identical to your servers internet name (not your servers FQDN, eg. webmodelling.com, not mail.webmodelling.com).

Test the installation : (The Ubuntu email server tutorial - Virtual domains - test it works have a more indept description of step 1-4 below)

  1. Create an email account :
    1. shell> mysql -u root -p : login to MySQL server.
    2. mysql> use Postfix; : change database to Postfix (uppercase P).
    3. mysql> show tables; : list the tables.
    4. mysql> desc domains; : list the columns of the domains table (there is only 1 column called domain).
    5. mysql> insert into domains (domain) values ('example.com'); : insert a virtual domain.
    6. mysql> insert into users (email, password) values ('rasmus@example.com', 'SomePassword'); : insert an email account.
    7. mysql> quit : leave the mysql client and return to system prompt.
  2. Send an email : (to the email account just created)
    1. shell> telnet localhost 25
    2. ehlo localhost
    3. mail from: root@localhost
    4. rcpt to: rasmus@example.com
    5. data
    6. Subject: my first subject
    7. My first body
    8. .
    9. quit : leave telnet on port 25 and return to system prompt.
  3. Check that the email message was delivered :
    1. shell> ls -l /home/vmail/example.com/rasmus/Maildir/new : there should be 1 file, the email message file.
  4. Retrieve the email :
    1. shell> telnet localhost pop3
    2. user rasmus@example.com
    3. pass SomePassword : you should now be logged in.
    4. list
    5. retr 1 : you should now see the whole email.
    6. quit : leave telnet on port 110 and return to system prompt.
  5. Test Squirrelmail :
    1. shell> ifconfig : find your serverIP.
    2. Open a browser and write http://ServerIP/squirrelmail into the url field : you should get the Squirrelmail login page.
    3. Set Name to rasmus@example.com (or whatever email account you created).
    4. Set Password to SomePassword (the password you created for the the email account).
    5. Press the Login button - you should now get the Squirrelmail INBOX folder for the email account you created.
  6. CONGRATULATIONS - you have a working email server.