Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I've got an application consisting of a number of web servers that use JavaMail to send outgoing mail via the gmail smtp server.

I'd like to have some centralized monitoring and control over the sending of mail so it seems likely that I'd want to introduce a local mail server through which all outbound mail from the web servers would be sent. I'd like (I think) to be able to query the newly introduced local mail server from the client (one of the web servers) to retrieve per-message sending status, and to make this useful the local mail server would ideally need some context information, provided when the mail is queued for sending, that links back to something meaningful on the web server (i.e. a transaction id).

The mail server would have a tool for the support team to view messages queued for sending, sent, and not delivered, with some decent search functionality and high level statistics.

Can anyone comment on if this seems a reasonable strategy and if there's any mail server products that might meet these requirements without too much customization? I stumbled upon Apache James but the documentation I've come across is at the API level and I've not seen any evidence of any GUI monitoring tools.

Thanks.

share|improve this question
    
Why don't you just add some logging for the mail sending functionality of your app? –  Sven Jul 3 '13 at 15:13
    
Basic logging is in place now, but we need something more resilient than that. For example if we had a temporary network outage that prevented connection to the gmail smtp server at the precise moment that a mail was being sent from a web server, then in the existing environment it would be lost forever. I'm envisaging being able to queue the mail on the "local mail server" and for it to retry the send a configurable number of times, and to be able to get an activity log of how many retries there have been, at what time etc.. Thanks for your reply. –  Oversteer Jul 3 '13 at 15:21
    
Sounds like you just want a local mailserver with GMail configured as the bridgehead. –  Chris S Jul 3 '13 at 16:59

1 Answer 1

You could make your Webservers only consider the 'send transaction' done when they receive the final '250 OK' from the mail server. If they don't get that, they should retry the send. That should take care fo the lost forever issue when the smtp server fails on the reception.

SMTP servers themselves have logic to keep retrying the sending of emails for a few times (configurable) when there is a failure. If the email is undeliverable you will get a bounce and should then evaluate what to do (retry or give up, depending on the reason for the bounce).

Since bounces can be asynchronous it is a bit difficult to build a query interface for specific messages, you may be able to send a message and still get a bounce hours or even days after the fact. So the status of a message could be changing from 'sent to smtp server' to 'bounced'.

You can build a webservice that you support can query by simply parsing those bounces and the logs from the webservers.

If you install a local mail server you can do a bit more on the configurations (how many times to retry, when, etc as you mention). But you still may get bounces after a message is 'delivered'...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.