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: 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:[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?