Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
703 views
in Technique[技术] by (71.8m points)

web services - How to communicate with a mail server through a web application

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...