4

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,foo@bar.com. 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: 127.0.0.1
  • 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:pi@bar.com: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' foo@bar.com

I receive the mail at foo@bar.com, and the sender is pi@bar.com.

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 Oct 27 '14 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 Oct 27 '14 at 11:45
  • I use a similar method and it can be made to retain a local copy and forward. See my A. – slm Oct 27 '14 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 Nov 10 '15 at 8:39
4

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

joe: joe, someaddress@someotherdomain.com

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

References

  • 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 pi@bar.com. – Sparhawk Oct 27 '14 at 13:11
  • Also, related. – Sparhawk Oct 28 '14 at 0:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.