I use the exim4 email package on Ubuntu configured as a "smart host". This means you give exim4 the user name and password for your normal SMTP server and it will send the email (from commands like mail and sendmail) through that.
Here is the question I asked about setting it up on AskUbuntu.com and the answer that I found:
I finally found a detailed set of instructions by Tony Scelfo that actually work. It appears that you have to use transport layer security (TLS) on port 587. I have not gotten SSL SMTP to work.
sudo dpkg-reconfigure exim4-config and use these config options:
- General type of mail configuration: mail sent by smarthost; received via SMTP or fetchmail
- System mail name: <your hostname>
- IP-address to listen on for incoming SMTP connections: 127.0.0.1
- Other destinations for which mail is accepted: <your hostname>
- Machines to relay mail for: <leave this blank>
- IP address or host name of the outgoing smarthost: mail.example.com::587
- Hide local mail name in outgoing mail?
- Yes - all outgoing mail will appear to come from your gmail account
- No - mail sent with a valid sender name header will keep the sender’s name
- Keep number of DNS-queries minimal (Dial-on-Demand)? No
- Delivery method for local mail: <choose the one you prefer>
- Split configuration file into small files? Yes (you need to edit one of the files next)
sudo vi /etc/exim4/passwd.client and add the following lines for your mail host, and any aliases it has (found through
nslookup). Substitute <email address> and <password> with the account you want to route mail through):
Once you edit the
passwd.client file, run
sudo update-exim4.conf which will integrate your changes into your Exim4 config.
sudo /etc/init.d/exim4 restart and make sure that the service stops and starts properly. If the service is unable to restart, something probably went wrong when you edited the
If Exim4 restarted, go ahead and run
sudo tail -f /var/log/exim4/mainlog to watch the mail logs. In a different window, send an email from your system and make sure that you see a record go by with
R=smarthost T=remote_smtp_smarthost H=gmail-smtp-msa.l.google.com ... X=TLS-1.0:RSA_ARCFOUR_MD5:16 in it. The
X=TLS means that the mail is being sent with transport layer security which is what you want.