Linux & Open Source

GMail as mail relay for your Linux home server

Since my Fedora Post-installation Configurations article, some things have changed in Fedora 20. For example, for security and economy reasons, Sendmail does not get installed anymore by default. Here are the steps to make your Linux home computer be able to send system e-mails as alerts or from things that run on cron. All commands should be run as user root.

  1. Install and configure stuff:
    yum install sendmail-cf patch wget cyrus-sasl-plain;
    wget -O /tmp/sendmail.mc.patch http://avi.alkalay.net/articlefiles/2011/01/sendmail.mc.patch;
    cd /etc/mail;
    patch < /tmp/sendmail.mc.patch;
    chmod go-rw authinfo;
  2. Edit the authinfo file and put your Gmail login and password.
  3. Configure the system so your mail address receives all mail for root. Do this editing /etc/aliases and make sure it has this line, generally at the very end:
    # Person who should get root's mail
    root:           YOUR-EMAIL-ADDRESS@domain.com
  4. Build new Sendmail configuration, update edited mail aliases database:
    cd /etc/mail;
    make;    # to regenerate the config files based on our changes
    newaliases;
  5. Create a key and a test certificate for Sendmail so Gmail will allow us to connect:
    cd /etc/pki/tls/certs;
    make sendmail.pem;
  6. Enable Sendmail on boot and start it:
    systemctl enable sendmail;
    systemctl restart sendmail;

Now the system is able to send you warnings, cron outputs etc by e-mail. To test it, you can do this as any user:

mail -a /some/file/to/be/attached -s "Subject line" recipient@somedomain.com <<EOF
Body of the message goes here...
EOF

The message will be sent with an attachment.

1 comment to GMail as mail relay for your Linux home server

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>