Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

We have a domain for a web site and e-mail that's hosted off-site. (We don't have a reliable enough connection to host it ourselves.)

Our shared host sometimes has SMTP problems, but never POP problems.

Is it possible to set up an e-mail server on CentOS 6.4 that will work internally (i.e. sending between e-mail addresses on our domain, even though our network domains are named differently than our web site) even if our Internet is down or our shared host's SMTP server is down, but will use our shared host's SMTP for outside addresses, and will still allow POP mail to be retrieved from the shared host, e.g. when we're at home or on the road?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

There are several possible solutions to this problem, and they're all fairly complex. This is the most transparent configuration I could think of, but honestly I would switch hosts if their SMTP service is unreliable. There are a lot of good, cheap providers of mail services. Also, consider using IMAP instead of POP3, as it will alleviate issues with synchronization likely to arise from such a setup.

The solution is complicated because of the necessary coupling between a Mail Transfer Agent (MTA) and a Mail Delivery Agent (MDA). In order for an email to exist on the POP3 server (the MDA), it must have been delivered through the unreliable SMTP server (the MTA). Your MTA can't store messages on the remote MDA, and the remote MTA can't send messages to your MDA. Without complete synchronization of messages in both directions, intra-company email (the "sending between e-mail addresses on our domain" part) sent from the office will only be stored on the local MDA. This means that users working away from the office would not receive internal emails when checking the hosted POP3 account.

You will need at minimum:

  • MTA for SMTP - Courier is the default for CentOS and a good choice
  • Firewall (for IP/port redirection) - netfilter or rinetd will work
  • MDA and Proxy for POP3/IMAP accounts - Perdition is probably best, Courier has this functionality

Local MTA for Backup SMTP

Add your mail host's SMTP server (the remote MTA) in /etc/courier/esmtproutes (or wherever that file gets installed on CentOS) to make Courier forward all messages to it. When your host's SMTP is down, the local MTA will queue outbound mail and retry delivery to the remote MTA at a configurable interval.

Port Redirection

Configure your firewall to forward all outbound traffic on port 25 to your local MTA.

You can implement only the above for the simplest configuration. It would not allow internal email to continue as normal, but it would make the remote MTA downtime less noticeable

Local MTA with Hosted Domain

Add your company domain as a hosted domain for Courier (the local MTA) in /etc/courier/hosteddomains. This will override the smarthost and deliver messages according to the configured routing rules. See makehosteddomains and Transport Modules for more information.

Local MDA and Proxy This can be implemented in many ways, but for example:

  1. Keep a local copy of email account credentials and use them to authenticate users to the local MDA, which could by default deliver to a "Local" folder for each user account
  2. Use courier-authlib/authpipe or Perdition to relay those credentials to the remote MDA at the same time, comprising the rest of the folders
  3. Set up a cron job to retry sending new messages in the "Local" folder to the remote MTA when the SMTP service is up

...Or implement internal DNS and:

  • Change MX preferences on the company domain, routing everything to both MTAs (would technically require two internal MTAs)

or

  • Just use a different (even fake) domain name for intra-office emails, and implement it as a failover system
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.