The most tricky part of these daemons is setting up the communication with the userbase, implemented by default as a MySQL database. This userbase is called 'mysqlplain' and is documented Section 10.1.
Connect to MySQL as a user that can create database, and issue the following statements:
$ mysql -u root mysql> create database powermail; mysql> use powermail; mysql> CREATE TABLE mboxes ( id int(11) NOT NULL auto_increment, mbox varchar(128) NOT NULL, password varchar(20) NOT NULL, quotaMB int(11) default '0', isForward tinyint(1) default '0', fwdDest varchar(80) default NULL, PRIMARY KEY (id), UNIQUE KEY mbox_index (mbox) ); mysql> INSERT INTO mboxes (mbox,password) VALUES ('info@example.com','s3cr3t!');
In this simple example, we will not mention mysql authentication but in real life you should use 'GRANT' statements to secure readonly access to your database.
Note that you also generated a mailbox called info@example.com, with password 's3cr3t!'.
Both powersmtp and powerpop need to be able to connect to MySQL. Because of these shared parameters, both read the file power.conf before parsing their own configuration files.
In power.conf, specify your 'mysql-host', 'mysql-user', and 'mysql-password'. Also set 'userbase' to 'mysqlplain' to use this MySQL database.
You are now mostly ready to launch the daemons, but it is likely that a mailer is already running. This is not a problem but another port or IP address for running PowerMail must be chosen. Alternatively, stop your existing mailer.
If you decide to use a separate IP address, create an interface alias for it. This will differ with your operating system. Next tell PowerMail about it. Again, the power.conf file is a apropriate file, as all daemons will bind to your IP address. A sample line might read 'listen-address=a.b.c.d', where a.b.c.d is your IP alias.
Another solution is to bind to another port, which is probably only useful for testing. As all daemons need a different port, specify this in powersmtp.conf and powerpop.conf using the listen-port parameter.
# /etc/init.d/powersmtp start powersmtp: started # /etc/init.d/powerpop start powerpop:started # /etc/init.d/powerpop status powerpop: PowerPOP functioning ok: +OK OK! # /etc/init.d/powersmtp status powersmtp: PowerSMTP functioning ok: 200 OK!
If anything is wrong, most likely with the MySQL connection, these scripts will warn you, but launch nonetheless. This is because a temporary database failure should not shutdown your mailsystem permanently.
Now run the 'pptool' command, installed by default in /usr/bin:
# pptool stat 127.0.0.1 3792 mb, 568720 inodes, load: 0.01, read/write accessIf there are any problems, for example with wrong passwords, this tool will inform you of them.
Next, we will test a sample delivery and retrieval of a message. First delivery, by hand, using the telnet tool. We will assume that powersmtp is running on port 25, but you might have chosen a different port for testing:
$ telnet 127.0.0.1 25 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. 220 snapcount PowerSMTP ESMTP mail from: ahu@ds9a.nl 250 Started message <1006724301:884450:snapcount.0> for sender <ahu@ds9a.nl> rcpt to: info@yourdomain.com 250 Added recipient 'info@yourdomain.com' to message <1006724301:884450:snapcount.0> data 354 Enter message, ending with '.' on a line by itself. Quota available: 50000 kilobytes From: ahu@ds9a.nl To: info@yourdomain.com Subject: test testing 1 2 3 . 250 Delivered message <1006724301:884450:snapcount.0> successfully to all recipients quit 221 bye Connection closed by foreign host.
Now let's see if this message has arrived with the 'pptool' command:
# pptool list info@yourdomain.com 127.0.0.1 done listing 'info@yourdomain.com', 1 messages 1006724301:884450:snapcount.0.1 127.0.0.1 162 1.2.3.4 162 1 messages, 0% non-redundant 0 kilobytes net
Next, we'll try to actually retrieve the message:
# telnet 127.0.0.1 110 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. +OK snapcount user info@yourdomain.com +OK pass 31337pw +OK list +OK 1 162 . retr 1 +OK Received: from 127.0.0.1:36724 by snapcount (PowerMail) with id <1006724301:884450:snapcount.0> From: ahu To: ahu@powerdns.org Subject: test testing 1 2 3 . quit +OK Connection closed by foreign host.