Distroname and release: Debian Squeeze

Use mail with SSMTP, to send through another mailserver / mailhub

It is quite simple, if you have some clients that are using the mail or mailx commandline tool, that will have to send e-mails through a mail hub, if the SMTP traffic is blocked by the ISP.

Installation

Simply install the ssmtp package.
#aptitude install ssmtp
Next reconfigure the ssmtp conf file.
Then all e-mails from this system will now send through the mailhub configured here. Unless ofcourse other applications are configured to do otherwise.
/etc/ssmtp/ssmtp.conf
root=postmaster
Mailhub=[192.168.1.2:25]
rewriteDomain=example.com
Thats it, everything is running.
If you have defined a username and password here, remember to chmod the file so only root, or the "superuser" have access to the file!

Authentication

If you do not define credentials for username and password to the remote server, remember to allow the ssmtp client to send through the mailserver.

The config can differ from setup to setup, but add the host to mynetworks, and be sure that mynetworks have permissions on the smtpd restrictions parameters.

192.168.1.10 are the IP of the client we just configured with ssmtp above.
Postfix example.
/etc/postfix/main.cf
mynetworks = 127.0.0.0/8, 192.168.1.10

smtpd_sender_restrictions =
    permit_mynetworks,
    ...other restrictions....

Changing sender address

It is possible to change the sender address, including domain name, or actually where it looks like the e-mail is original comming from.
But it depends on your setup on your mailserver if this is possible or not!

It is quite simple, just by changing the /etc/ssmtp/revaliases file. The parameters are as follows:
localusername:email@example.com:mailhub:port
So now we will define the setup for a local client user called JohnJoe.
We also have a default sender for the root user.

Remember it is possible to specify another domain than the one we have defined in the ssmtp.conf file.
/etc/ssmtp/revaliases
JohnJoe:johnjoe@example.com:192.168.1.2:25
root:admin@example.com:192.168.1.2:25
SuperUser:super@example2.com:192.168.1.2:25

Notes

It is also possible to use TLS with ssmtp, which is very nice. Check the man pages for this.
Copyright LinuxLasse.net 2009 - 2017 All Rights Reserved.

Valid HTML 4.01 Strict Valid CSS!