I am interested to get email notifications from my server to my Gmail account - the same notifications that the server gets in the /var/mail/root - either by forwarding the messages, or or directly emailing the notifications there (which one is better for security?) The Gmail account is set to have two-step-authentication for security reasons.

How can I do this on a Debian Jessie?

Following @tarleb recommendations, I found Gmail's application specific login:

Now, how to use this with Debian? is exim4 still a good package to use? Is it safer/better to forward the emails to Gmail? Or better skip the internal root mail altogether?

Update I did follow the tutorial on VUTLR, but I am getting the following error:

root@vultr:/etc/exim4# update-exim4.conf

2015-12-07 11:05:18 Exim configuration error in line 22 of /var/lib/exim4/config.autogenerated.tmp:
malformed macro definition

Invalid new configfile /var/lib/exim4/config.autogenerated.tmp, not installing /var/lib/exim4/config.autogenerated.tmp to /var/lib/exim4/config.autogenerated

  • Do you want to forward received mail from your server to your Gmail address, or do you want to send mail from your server to arbitrary locations via Gmail? It's not clear from how the question is posed.
    – tarleb
    Dec 7, 2015 at 15:02
  • Either will work. I seen older posts discussing it with different methods. But I reluctant following those older posts because they are from pre 2009. Dec 7, 2015 at 15:04
  • 2
    The short version is: 2fa doesn't make much sense when used in an automated setting. Set up an application specific password on Google and use postfix with SASL and transport maps to send your mails. Somebody else might be able to turn this into a proper answer (I don't have enough time right now, sorry).
    – tarleb
    Dec 7, 2015 at 15:12

1 Answer 1


I was able to get it running by creating an app specific password (as noted in the question). Then followed the tutorial on VULTR. But I was getting an error:

Exim configuration error in line 22 of/var/lib/exim4/config.autogenerated.tmp:

malformed macro definition

I had to apt-get remove --purge exim4-config to get it all cleaned up. Then reinstalled exim4 by apt-get install exim4.

  • I don't know much about exim, but googling turned up are some quite decent tutorials using postfix. Please let us know if you got it to work.
    – tarleb
    Dec 7, 2015 at 19:37
  • i was reading a bunch on this topic. And it is claimed the exim4 is Debian's default mailing package. But it did not come with it, postfix did. I am able to send mail via exim4, but I am not sure yet if the system does send emails as alerts (doing offline stuff now) Dec 7, 2015 at 19:41
  • 1
    Exim is the default as it's GPL licensed, while postfix is published under an IBM license. It is still free software (as defined by the FSF) but incompatible to the GPL. However, I'd claim that most people prefer postfix, as it has a clean design, is (relatively) simple to configure and has a very good security record. One would probably be able to get this working with exim, but there are probably more resources available to those using postfix.
    – tarleb
    Dec 7, 2015 at 19:48

You must log in to answer this question.

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