views:

2016

answers:

4

My VPS provider (Slicehost) doesn't provide an SMTP server. I use Google Apps to send and receive mail for my domains, but I want to be able to programmatically send e-mail.

I've been Googling this issue on and off for many months, and I just can't seem to get a clear picture of what I need to do. Do I just need an MTA like postfix? Do I configure it as a "satellite", or an "internet" site? Do I need to make any DNS changes? If I want to programmatically receive e-mail someday, are there any configuration options I should be careful about tinkering with? Also, if my VPS host did provide an SMTP server, what wouldn't I need to do, that I'm doing now?

Thank you!

Edit: A quick synopsis of my findings:

  • Update /etc/hosts and /etc/hostname to reflect the FQDN (for example, mail.domain.com or sub.domain.com instead of slicename)
    • Reboot and verify with hostname -f
  • Set up reverse DNS (which is owned by whoever owns the IP pool) to point at the same FQDN
    • Check that the RDNS has propogated with dig -x server.ip.address
  • sudo aptitude install postfix telnet mailx
    • Use internet site setting
    • Set FQDN to whatever was chosen above
  • Test with mail [email protected]
+3  A: 

Have you looked here, seems to me that there is plenty of information to get started. I found mail-server-slice-setup to be quite informative.

Scott Bennett-McLeish
Coincidentally, I've been pondering getting a slice going some day soon, this might've just given me that last little shove to do it.
Scott Bennett-McLeish
Also found this (http://jonsview.com/2008/07/14/setting-up-email-services-on-ubuntu-hardy-using-postfix-and-courier) which could be handy.
Scott Bennett-McLeish
A: 

Just install something like postfix as "internet site" and you'll be able to send mails directly from your VPS

it should work with default settings but it would be recommended to also read a few docs/how-to's to secure it properly

daniels
+2  A: 

To my experience, when email providers check for spams, they check 5 main things other than content: (When I say domain, I'm referring to the domain of the sender's email address.)

  1. "A" record (IP) of the domain name exists
  2. MX records of the domain name exist
  3. PTR record (Reverse lookup) of the sender's IP address exists (Sometimes, I think it is also checked to see if the PTR record has the same A record as the original domain)
  4. SPF record of that domain matches the IP number (This is a list of IP numbers allowed to send emails of that domain. Although this would be a great solution for spam filtering, this is not an official record, so it is not always checked. Check out the SPF setup wizard.)
  5. The IP segment of the server is not a blacklisted segment.

The fourth one is the one that was a problem for me. Apparently email providers such as Hotmail, Gmail, Yahoo drop all incoming email from widely used server providers such as Amazon EC2. In that case, there's simply no way to guarantee the delivery of all outgoing emails, so you would have to relay all outgoing email from some other SMTP server outside the blacklisted segment. The easiest way to do this is configuring Postfix (or whatever MTA you're using) to automatically relay all emails. You can find plenty of articles on this if you do some googling.

If that is not the case, then all you need is a simple MTA like Postfix, as long as all the necessary DNS records listed above are configured properly, you should have no trouble sending emails.

Murat Ayfer
+1  A: 

Other answers have provided information about the mechanics of sending email, but one thing you need to consider is what sender address you're going to use, and how you're going to deal with bounce messages.

Let's say you're sending emails from [email protected]; then (as Murat Ayfer noted) you need to make sure that your host is allowed to send mail according to example.com's SPF record. (This may or may not be configured by IP address -- see the SPF site for more details.) If you're in charge of the example.com domain, then this shouldn't be a problem. Being listed as an acceptable sender for the domain is an important step towards your emails getting through.

The next thing you need to worry about is how to deal with bounced emails. If some other host receives emails for example.com (i.e. the MX record points elsewhere), then it's mainly someone else's problem. (Note however that your application has to be prepared for a failure during the SMTP session to the mailserver on your host, due to syntactically invalid email addresses, for example.) But if you decide that you'll receive mail for example.com on your host, then you need to worry about dealing with retry messages, bounce messages, double bounce messages, and a whole lot of other general mail server administration. There's some info on handling undelivered emails in web applications which might be helpful, but I also suggest getting a good book on Postfix or whatever mail server you decide to use.

TimB