Automate packages provide a console-based, interactive way to configure complete server solutions. This package installs and configures a Postfix/Dovecot/MySQL SMTP/IMAP/POP3 server on a Linux system. If you don't have a server of your own, check out Linode, my favorite server provider. This software is essentially designed to automate the steps provided in the Linode Library Host Email with Postfix, Dovecot and MySQL on Ubuntu 10.10 (Maverick Meerkat) guide.
You must create MX records for each domain you wish to host email for. If you're using a Linode VPS and you are using the Linode DNS Manager interface to manage DNS for your domains, you may refer to the Linode Library article on DNS configuration with the Linode Manager for easy instructions.
For each of your domains, create an MX record that refers to a A record pointing to your server's IP address. By default, the Linode DNS Manager creates an A record called "mail" that points to your Linode's IP address. In this case, you may use "mail.example.com" (substituting your domain name for "example.com") in your MX records.
Log into your system as the "root" user. If you are running the 32-bit (x86) version of Ubuntu 10.10, issue the following commands to obtain, unpack, and run the software.
apt-get install wget bzip2 wget https://www.palegray.net/projects/automate/pdm/download/pdm-ubuntu-10-10-x86-v1.0.1.tar.bz2 bunzip2 pdm-ubuntu-10-10-x86-v1.0.1.tar.bz2 tar -xf pdm-ubuntu-10-10-x86-v1.0.1.tar cd pdm-ubuntu-10-10-x86-v1.0.1 ./install
If you are running the 64-bit (x86_64) version of Ubuntu 10.10, issue the following commands to obtain, unpack, and run the software.
apt-get install wget bzip2 wget https://www.palegray.net/projects/automate/pdm/download/pdm-ubuntu-10-10-x86-64-v1.0.1.tar.bz2 bunzip2 pdm-ubuntu-10-10-x86-64-v1.0.1.tar.bz2 tar -xf pdm-ubuntu-10-10-x86-64-v1.0.1.tar cd pdm-ubuntu-10-10-x86-64-v1.0.1 ./install
Once you've provided the requested configuration values, Postfix, Dovecot, and MySQL will be configured to provide SMTP, IMAP, and POP3 email services on your server.
A management program called manage is included, allowing users to easily handle domains, accounts (email addresses), and forwarding of accounts to other destinations using simple shell commands. Here's the help output from the manage program:
Usage: manage [function] [action] [function arguments] manage domain list List all email domains manage domain add [domain name] Add email service for domain [domain name] manage domain remove [domain name] Remove email service for domain [domain name] manage domain purge [domain name] Remove email service for domain [domain name] and purge existing emails manage account list [domain name] List email accounts for domain [domain name] If [domain name] is not specified, lists accounts for all domains manage account add [username]@[domain name] [password] Add email service for [username]@[domain name] manage account password [username]@[domain name] [password] Update the password for [username]@[domain name] manage account remove [username]@[domain name] Remove email service for [username]@[domain name] manage account purge [username]@[domain name] Remove email service for [username]@[domain name] and purge existing emails manage forward list List all email forwards manage forward list [source domain name] Lists email forwards for [source domain name] manage forward add [source email] [destination email] Forwards email from [source email] to [destination email] manage forward remove [source email] Stop forwarding email from [source email] to another address
Since all email domain, account, and forwarding information is stored in a MySQL database on your server, you may control its operation with SQL statements if desired. This allows users to easily integrate control of their mail server into other applications, such as web-based control panels.
To view a list of active email domains, issue the following commands. You will be asked to enter the MySQL mail database password you assigned during installation. Substitute your email database user for "email_db_user" and your email database name for "mail" is these commands.
mysql -u email_db_user -p USE mail; SELECT domain FROM domains;
To view a list of active email users for a domain, issue the following command, substituting the desired email domain for "example.com".
SELECT email FROM users WHERE email LIKE "%@example.com";
To add a new email domain, issue the following command, replacing "example.com" with your new domain name.
INSERT INTO domains (domain) VALUES ('example.com');
To add a new email user, issue the following command, replacing "email@example.com" with your new user's email address, and "password" with the user's email password.
INSERT INTO users (email, password) VALUES ('firstname.lastname@example.org', ENCRYPT('password'));
After adding a new email user, issue the following command at a normal shell prompt to send an initial welcome message to the user. This is required, as the user's mail account won't be accessible via IMAP or POP3 until a message is sent to it. Be sure to replace "email@example.com" with your new user's email address.
echo "This is a welcome message. Feel free to delete it." | mail -s "Welcome message" firstname.lastname@example.org
To update an email user's password, issue the following command, replacing "email@example.com" with the user's email address, and "password" with the new password.
UPDATE users SET password = ENCRYPT('password') WHERE email = 'firstname.lastname@example.org';
To forward email from one account to any other email address, issue the following command, replacing "email@example.com" with the user's email address, and "firstname.lastname@example.org" with the destination email address.
INSERT INTO forwardings (source, destination) VALUES ('email@example.com', 'firstname.lastname@example.org');
To quit the MySQL shell, issue the command "quit".
The full source code for this package is available here: pdm-ubuntu-10-10-v1.0.1-source.tar.bz2. You may also obtain the software via git by issuing the following command.
git clone http://git.palegray.net/Automate/pdm-ubuntu-10-10
Please report any bugs or feature requests to Phil Paradis <email@example.com>.
Copyright © 2011, 2011 Philip C. Paradis <firstname.lastname@example.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PHILIP C. PARADIS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software uses the Term::ReadKey Perl module. The "README" for this module contains the following text related to copying:
"Term::ReadKey 2.13 - Change terminal modes, and perform non-blocking reads.
Copyright © 1994-1999 Kenneth Albanowski. Unlimited distribution and/or modification is allowed as long as this copyright notice remains intact."