Following from the previous article, we now have our firewall opening the correct ports.
Now we can start adding domains and users to the MySQL 'mail' database.
Contents |
We're going to be using the MySQL command line to add the domains and users.
You can, of course, use PHPMyAdmin or other MySQL GUI if you prefer. I'll leave that to you.
However, if you are using a GUI to add the details, make sure that when you add a user's password, you enter it using the MySQL 'ENCRYPT' function.
Let's log into MySQL:
mysql -u root -p
You will be prompted to enter your MySQL root password.
Once logged in, ensure you are using the 'mail' database:
USE mail;
Note the semicolon (;) at the end of the command. This lets MySQL know the command is to be executed - nothing will happen if you leave it off.
To add a domain is very simple:
INSERT INTO `domains` (`domain`) VALUES ('democloudserver.com');Note the use of backticks (`) in the first two fields and the use of single quotes (') when entering that actual value.
To add another domain uses exactly the same procedure:
INSERT INTO `domains` (`domain`) VALUES ('testdomain.com');
Adding a user email and password takes the same format:
INSERT INTO `users` (`email`, `password`) VALUES ('paul@democloudserver.com', ENCRYPT('secretpassword'));Three things here:
Firstly, similar to when adding the domain details, note the distinction between backticks (`) and single quotes (').
Secondly, you must use the MySQL 'ENCRYPT' function when adding the password.
Lastly, change the 'secretpassword' to a more secure one of your choosing!
To add another user for the same domain:
INSERT INTO `users` (`email`, `password`) VALUES ('onion@democloudserver.com', ENCRYPT('secretpassword'));and to add a user for the 'testdomain.com' domain:
INSERT INTO `users` (`email`, `password`) VALUES ('jeff@testdomain.com', ENCRYPT('secretpassword'));Once done:
quit;
That will place you back at the command prompt.
As we have made changes to database, we will need to reload postfix:
sudo postfix reload
Have a look at where the mail will be physically located:
ls /home/vmail
You will see that the folder is empty.
The correct folders are only created on receipt of the first email.
So. let's do just that by sending an email from the command line:
mail jeff@democloudserver.com
Enter a subject and body, then enter a single period (.) to indicate the message is ended.
Now look at the /home/vmail folder:
ls /home/vmail
You will see a new folder has been created named 'democloudserver.com':
/home/vmail/democloudserver.com
You will need sudo permissions to go any further and examine the contents of the democloudserver.com folder.
However, for each user under democloudserver.com a folder will be created. If we look back up to when I created my users, I had 'jeff' and 'onion'. I sent a new email to each user and now the folder structure looks like:
/home/vmail/democloudserver.com/jeff ... /home/vmail/democloudserver.com/onion
Sending an email to the second domain (in my case, jeff@testdomain.com) will create a 'testdomain.com' folder and so on.
Make sure you send an email to each account you create - this will ensure the file structure is created.
Adding domains and multiple users is very easy using the MySQL command prompt.
Once created, send an email to the new user and the relevant file structure will be automatically created.
Now the mail server should be ready for use.
© 2011-2013 Rackspace US, Inc.
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License

17 Comments
I finished the article series
RE: I finished the article series
Hi rae.cabello, i used both
RE:
I followed all pages of this
Re: vmail user
Can't telnet in
telnet: connect to address my-ip: Operation timed out
telnet: Unable to connect to remote host
My Firewall settings all seem correct. I've also tried removing all the settings from my firewall, and still nothing happened.
I've slightly fixed the
5.7.8 Error: authentication failed: no mechanism available.
Re: Remote SMTP
http://www.rackspace.com/knowledge_center/index.php/Postfix_-_Basic_Settings_in_main.cf
And check some advice on testing with telnet in this article:
http://www.rackspace.com/knowledge_center/index.php/Postfix_-_Using_Telnet_to_Test_Postfix
We usually recommend using a third party to send email from a remote client, like Gmail or Rackspace Email, since it can be hard to maintain an SMTP server that allows sending from remote clients. If you do, make sure you at least test it to make sure it isn't an open relay once you have everything working to your satisfaction. You can do that from this site:
http://www.abuse.net/relay.html
I found the problem! It's a
Re: chroot
So I tested the mail server
Both methods worked and I was able to go into the directory and verify the messages.
Below is the output from the telnet output:
telnet topitoff-cupcakes.com 25
Trying 50.57.228.145...
Connected to topitoff-cupcakes.com.
Escape character is '^]'.
220 helen.topitoff-cupcakes.com ESMTP Postfix (Debian/GNU)
HELO andi.topitoff-cupcakes.com
250 helen.topitoff-cupcakes.com
mail from:<andi@topitoff-cupcakes.com>
250 2.1.0 Ok
rcpt to:<kalyn@topitoff-cupcakes.com>
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
subject: test message
this is the body of the message!
.
250 2.0.0 Ok: queued as B2A691828C
quit
221 2.0.0 Bye
Connection closed by foreign host.
I followed the directions,
Also setting the up a client ( OS X mail) for some reason it doesn't take the password.
1. I doubled checked the
2. After seeing the mail logs, the first error I noticed was the certificate had the wrong extension so that's correct.
3. Now the other error that's in the mail logs is:
mail.info:
Jun 29 11:27:47 helen imapd-ssl: LOGIN FAILED, method=PLAIN, ip=[::ffff:50.81.64.168]
Jun 29 11:27:47 helen imapd-ssl: authentication error: Input/output error
mail.warn
Jun 29 11:23:15 helen imapd-ssl: authentication error: Input/output error
Jun 29 11:27:47 helen imapd-ssl: authentication error: Input/output error
I'm not really sure what the
The article refers to
re: backticks
Backticks are used in place of single-quotes when you might need to use special characters or want to use a field name that might be a keyword in SQL. Some admins use them as a sort of future-proofing, so that a database server upgrade later that introduces a new keyword won't conflict with their field naming scheme.
Add new comment