5

I am really unfamiliar with mail servers in general so please excuse my ignorance.

I need to be able to administer a mail server through my Spring-based web application. By administer, I mean creating mail accounts for new users, listening for incoming updates from those users, deleting accounts, when user accounts are deleted, etc, etc, etc.

I assume that mail servers (at least the good ones) provide some sort of a service API (SOAP, REST, it doesn't matter) through which an application can hook, and make changes. However, i am really unfamiliar with regards to what the good open-source servers out there are, and what options they provide.

I will be glad if someone, could propose a solution.

user802232
  • 2,541
  • 7
  • 34
  • 40
  • What do you actually want to do with the mail server? Offer users mailboxes, send email from your app, receive it? I think the answers will vary depending on your actual aim. I know you have listed a couple of things but they're actions not what you are doing with it. – Steve Smith Jun 22 '11 at 07:35
  • Let's say for now I want to create a mail account per user who registered in the system. How do I do that with the least pain? – user802232 Jun 23 '11 at 10:05
  • In the worst case I can use sendmail, and call it from the Spring app, by passing the necessary params to it. – user802232 Jun 23 '11 at 11:49
  • Are you using a specific mailserver? – abalogh Jun 28 '11 at 10:19
  • @abalogh I will give Zimbra a try. Hopefully, it does stuff properly. Currently I am using just plain sendmail, and was going to write some wrappers for it. – user802232 Jun 28 '11 at 11:49
  • maybe worth checking this: http://www.linuxquestions.org/questions/linux-server-73/zimbra-vs-qmail-and-sendmail-856744/. By the way i'm in no way affiliated to Zimbra, just found it while googling, but now that I've read some about it, it really seems mature and actively developed/maintained as well – abalogh Jun 28 '11 at 11:59
  • @user802232: have you thought about rewarding that bounty? – abalogh Jul 05 '11 at 09:31

2 Answers2

4

A possible solution is to use software with a generic database plugin. Your web application does not interact with the mail server, instead it just fills a users table in a mysql database. in the simplest case this table has a username field and a password field. In most real-life setups a few additional fields are required like "user is disabled" or "user can connect with IMAP", "location of users homedir/maildir", ... If your users can create new domains as well, you also need a table for that.

Then, you need mail server software with a database backend.

For hosting the mailboxes, you could use the dovecot IMAP/POP3 server. It supports all the fancy stuff like user quota, auto-creation of mailboxes etc. Here, you'll find documentation on how to configure dovecot with a database backend: http://wiki2.dovecot.org/AuthDatabase/SQL

For actually receiving the mail by stmp you also need a MTA software. Here, a good choice would be postfix. If your users can create new domains, you need to add mysql configuration that tells postfix which domains it may accept mail for. Since I don't know your domain requirements exactly I'm just going to point you to the general postfix virtual domain hosting howto: http://www.postfix.org/VIRTUAL_README.html

Finally, if your users should be able to send mail as well you need to configure SASL in postfix. This is quite simple if you already have dovecot configured. it boils down to telling postfix "hey, I already have user authentication configured in dovecot, I don't want to do it again, just talk to dovecot and let it do the job". Documentation is here: http://www.postfix.org/SASL_README.html#server_dovecot

Gryphius
  • 75,626
  • 6
  • 48
  • 54
3

There is a mail server called Zimbra which has an open source community edition, which has a REST interface and also a SOAP one.

  • REST reference (if I understand correctly this won't suit your needs because you can only manipulate existing account via this)
  • SOAP interface; one example here, there are many others on the forum.
abalogh
  • 8,239
  • 2
  • 34
  • 49