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?
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 theX=
information in/var/log/exim4/mainlog
. If it mentionsTLS
, the communication was encrypted. – Run CMD Nov 10 '15 at 08:39