Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for the simpliest way to be able to send admin emails (backups, notifications) from an ubuntu server to my gmail address.

What is the best way to do that ? Should I just create a gmail account and use imap ? Or should I install postfix or something similar ? (I'm concerned about keeping it lightweight and avoid the need for too much configuration/security tweaks).

Thank you!

share|improve this question
possible duplicate of Setup ubuntu server to send mail() – GregD Nov 19 '10 at 12:11
up vote 3 down vote accepted

Just install Postfix. Default installation (internet site) will do.

In /etc/aliases add yourself as the alias to root


You have to also run newaliases to update the indexed db file.

share|improve this answer
As long as there is no firewall blocking outgoing SMTP this will work just fine. Otherwise you might have to configure postfix to use a smarthost. +1 – pehrs Nov 19 '10 at 14:13
@pehrs: yeah that is true. +1 – cstamas Nov 19 '10 at 15:29
thanks cstamas! – Thibaut Barrère Nov 20 '10 at 15:57
Postfix is usually overkill IMO, I use nullmailer to keep a minimal footprint. – NginUS Nov 21 '10 at 11:29
I wasn't aware of nullmailer and looked at it - apparently it works by connecting itself to remote smtp, right ? – Thibaut Barrère Nov 21 '10 at 13:11

If any of your servers are hosted a well known source for spam - which now include many cloud providers and hosters, any alias forwarding to gmail (or any such webmail provider) is likely to fail due to RBL policy.

What i usually do is setup a "google app for your domain" account, and add the necessary SPF record to the DNS zone so that google MXs will accept mail relayed through my hosts.

share|improve this answer
Well thank you - I just figured this out during my tests (my emails gradually went to spam then ended being delivered!). I believe I'll use SendGrid or Google Apps. – Thibaut Barrère Nov 23 '10 at 19:59

If you have mail setup, you use mailx to send out email from a script... | mailx -s "results from backups"

echo "just a test" | mailx -s "please ignore this"

cat << EOF | mailx -s "more tests"

this is a long

test of email in a

shell script


share|improve this answer

It seems that configure sendmail to send through Gmail SMTP is easier for you.

share|improve this answer
I think this is neither easy nor necessary. – cstamas Nov 19 '10 at 12:50

Your Answer


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.