I want to host an email server on my VPS so I can send automated emails from my application. Reading about the different ways of hosting email servers (involving ISPs blocking ports, open relay issues, authenticated SMTP, SSL, etc.) has left me very confused.

Most tutorials advise to use a smart host as a relay. I don't want to do this because I don't want to depend on an outside service. So my question is what are the things I need to think about to send email to the Internet?

A link to a simple clear tutorial would be appreciated because I was not able to find one.

  • 1
    Point the first: Don't be an open relay. Point the second: See the first point. Commented Jul 6, 2013 at 23:54
  • 1
    "I don't want to depend on an outside service." What hekevintran wrote. Do it yourself, if you possibly can. Don't let corporations take over the internet, they way they have Real Life.
    – user732
    Commented Jul 7, 2013 at 1:06
  • Which Linux distro are you planning on using on the VPS?
    – slm
    Commented Jul 7, 2013 at 7:46
  • @IgnacioVazquez-Abrams: while that is obviously still sound advice, it stopped being sufficient more than a decade ago.
    – tripleee
    Commented Jul 7, 2013 at 8:19

2 Answers 2


A mail server is only required if you're looking to receive mail. Even this can be avoided by using a tool such as fetchmail (for receiving).

In general it's probably best not to setup a mail server, given the extra work involved in having to maintain it. If you really want to though, I've conveniently put together a tutorial titled: How to Setup a Mail Server on CentOS 5 on my blog. It covers how to setup a sendmail based mail server with all the add-ons (spamassassin, virus checking, etc.).

Usually all that's needed to send mail is the ability to queue messages, and then periodically deliver them. What this means is that you can setup something like this, using sendmail.

Create the file /etc/mail/sendmail.mc:

define(`SMART_HOST', `your-smtp-server')

Then run this command:

$ m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

excerpt from the Fedora Project

The following article explains the setup of sendmail for forwarding mails to your ISP's smtp server. It is assumed that you have sendmail up-to-date and configured properly. Note: this setup does not work properly for smtp-server using SASL (e.g. like smtp.pobox.com) Most of the commands must be executed with the corresponding rights (using sudo).

Create/Edit the file /etc/mail/authinfo:

AuthInfo:<your-smtp-server> "U:<your-smtp-user>" "P:<your-smtp-password>" "M:DIGEST-MD5"

Set it's permissions:

$ chmod 600 /etc/mail/authinfo

Rebuild the authinfo file:

$ makemap hash /etc/mail/authinfo < /etc/mail/authinfo
-or on Red Hat based systems-
$ make 

Restart the service:

$ /sbin/service sendmail restart


  • For a beginner, I would suggest Postfix over Sendmail. In fact, unless you're already stuck with Sendmail, I would suggest Postfix.
    – tripleee
    Commented Jul 7, 2013 at 7:40
  • @tripleee - I have no practical experience in setting up Postfix so I can't say anything to it - I know it's the default on distros such as Ubuntu, but in general I always nullclient my systems to a central mail server in which case I believe it's equally as trivial in Sendmail & Postfix. Do you know of any good tutorials (obviously I could Google for them), but if you know of any I'd be happy to incorporate them into this answer.
    – slm
    Commented Jul 7, 2013 at 7:50
  • The top Google hits tend to be good, often pointing to documentation right at Postfix.org. Ralf Hildebrandt's resources are also well respected. Or try your particular distro or platform; the top Google hit for "postfix centos5" is wiki.centos.org/HowTos/postfix
    – tripleee
    Commented Jul 7, 2013 at 7:57

With your independence from an individual ISP or email provider on one hand, you really have to calculate, on the other, how much time you are willing to spend on maintaining your reputation as an email sender. Because of how the spammers and malware peddlers are abusing the email system, it has been polarized to the point where the absence of a strong positive reputation is already a negative reputation. Yesterday you had to worry about technicalities like open relays and egress filtering, then came SPF and SenderID, now it's DKIM and DMARC, tomorrow it will be something else again. Unless you are prepared to invest in becoming specialized just in order to merely keep up, my advice would be to use an established email service. That doesn't mean you cannot switch; look for someone who can help establish and maintain a reputation for your domain name(s), rather than using their own.

  • You might want to explain the acronyms a bit. Remember most people are completely oblivious to things like SPF, DKIM, etc. More so here than on say ServerFault. Might seem excessive but it'll make your answer much more universal as people stumble into this question down the road. Also I'd throw the links you mentioned about Postfix into the answer as a reference section at the bottom.
    – slm
    Commented Jul 7, 2013 at 8:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .