On my Raspbian server, I wish to have local *nix mail delivered locally, as well as to an external address. /home/pi/.forward contains pi,[email protected]. I've run sudo dpkg-reconfigure exim4-config with the following options.

  • mail sent by smarthost; received via SMTP or fetchmail.
  • System mail name: raspberrypi.
  • IP-addresses to listen on for incoming SMTP connections:
  • Other destinations for which mail is accepted: none.
  • Machines to relay mail for: none.
  • IP address or host name of the outgoing smarthost: smtp.bar.com:465
  • Hide local mail name in outgoing mail? Yes.
  • Visible domain name for local users: bar.com
  • Keep number of DNS-queries minimal (Dial-on-Demand): No.
  • mbox format in /var/mail/
  • Split configuration into small files? No.

Note that I've set the apparent sending domain as bar.com, as I suspect my SMTP server requires that. I've then added the associated credentials in /etc/exim4/passwd.client, i.e. smtp.bar.com:[email protected]:PASSWORD. Then I've run sudo update-exim4.conf; sudo invoke-rc.d exim4 restart; sudo exim4.

Testing, if I send mail to an external address, it works fine.

echo -e "Test body" | mail -s 'Subject' [email protected]

I receive the mail at [email protected], and the sender is [email protected].

However, if I send it to the local address, it only goes to the local address.

echo -e "Test body" | mail -s 'Subject' pi

In this case, the sender is pi@raspberrypi, which probably makes the SMTP server reject it. How can I send mail to both the local server and the external?

  • If you're using postfix on Pi: blog.bobbyallen.me/2013/02/03/…
    – slm
    Commented Oct 27, 2014 at 11:44
  • @slm I'm not sure if I'm using postfix, but that link is for forwarding to an email address without keeping a local copy, if I read it correctly. (and similar to my first link)
    – Sparhawk
    Commented Oct 27, 2014 at 11:45
  • I use a similar method and it can be made to retain a local copy and forward. See my A.
    – slm
    Commented Oct 27, 2014 at 11:46
  • With Debian 8 and a hosting provider, I'd like to add: If you want to use TLS, it's not required to directly specify a port; and it mey even fail. exim4 does not support immediate TLS on any port. So if the above does not work for you, try to omit the port and look for the X= information in /var/log/exim4/mainlog. If it mentions TLS, the communication was encrypted.
    – Run CMD
    Commented Nov 10, 2015 at 8:39

1 Answer 1


With most mailers you can do something like this in the /etc/aliases file.

joe: joe, [email protected]

After making changes to this file you typically have to run the command, newaliases.


  • Oh great! Yes, that seems to work fine. I'm not sure how it does it, but the sender makes sense too. For the local copy, it's from pi@raspberrypi, and for the external copy, it's from [email protected].
    – Sparhawk
    Commented Oct 27, 2014 at 13:11
  • Also, related.
    – Sparhawk
    Commented Oct 28, 2014 at 0:26
  • But how does the machine know how to send the mail to [email protected]? Do you have to put in the details of an SMPT server somewhere? Commented Oct 13, 2021 at 21:24

You must log in to answer this question.

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