Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 280
  • Last Modified:

Setting up e-mail


I have three domains on a dedicated server running FreeBSD. Now I want to setup an e-mail server for these three domains and be able to setup accounts for each of them. I want to access it by POP3.

I'm not an expert, so I need the easiest server availible. It is very important that it is easy to configure.

Any suggestions?

1 Solution
With the provision that the email user names must be unique across the server (the email addresses for the virtual domains don't have to be unique), you've probably got everything that you need  readily avaliable. I don't know if you installed the Univ of Washington IMAP server when FREBSD was installed, but you can easily add it from the ports collection. That will handle IMAP or POP access to the inboxes and FreeBSD already has sendmail installed.

With an IMAP/POP server installed the next thing you need to do is to create a FreeBSD account for each email user. Those users don't need shell access to you system (and probably shouldn't have that). Setting the user shell to /bin/false will prevent them from actually logging into the system.

You need to be sure that the DNS records for each of your domains contains an MX record that points to your server. Assuming that its hostname was myserver.somedom.tld the MX record for each virtual domain that you host would look something like

       IN MX 10  myserver.somedom.tld

Next you'll need to configure sendmail to handle mail for each of your virtual domains. For the purpose of illustration I'll assume that those domains are virt1.tld, virt2.tld, virt3.tld. Sendmail needs to be told that it handles email for those domains by editing /etc/mail/local-host-names to contain:


Each time the local-host-names file is changed sendmail must be restarted, typically something like:

killall sendmail
/usr/sbin/sendmail -bd -q1h

The incoming mail will be distributed to user's inboxes by the contents of /etc/mail/virtusertable, which might contain something like:

postmaster@virt1.tld    root
webmaster@virt1.tld     webguru
sales@virt1.tld         billy-mac
info@virt1.tld          billie-sue
@virt1.tld              virt1-owner
postmaster@virt2.tld    root
webmaster@virt2.tld     webguru
sales@virt2.tld         suzie
info@virt2.tld          william
@virt2.tld              virt2-owner
postmaster@virt3.tld    root
webmaster@virt3.tld     webguru
sales@virt3.tld         tony
info@virt3.tld          meridith
@virt3.tld              virt3-owner

Each of those virtual domains contains a catchall entry (@virt?.tld) the redirects mail not matched by another rule to the virt?-owner. The virtusertable needs to be turned into a map file each time it is changed with:

makemap hash /etc/mail/virtusertable </etc/mail/virtusertable

There are several other things you can do with virtusertable and you can read about them and virtual hosting in general at http://www.sendmail.org/virtual-hosting.html

With all of that set up the users (billy-mac, billie-sue, etc) should be able to use POP (or IMAP) to connect to your server (myserver.somedom.tld in this example) and retrieve mail.

The bigger problem is in letting your email users send mail back through your mail server. There's no problem  if the mail is to an address on your server, but if the address is some Internet host you'll run afoul of the anti-spam provisions (which will prevent relaying). How to solve that problem depends on whether the email users have fixed IP's or random, changeable, IP's. In the former case you can use statements like:    RELAY    RELAY

in /etc/mail/access (and make a new access map) to allow those users to relay through your server. In the later case the best solution is to build Cyrus-SASL and a new copy of sendmail that includes SASL support. Then the users can authenticate to the SMTP server which will allow those user to relay mail. There's a good discussion of this at http://www.sendmail.org/~ca/email/auth.html 


Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now