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.


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.
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!


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. are the IP of the client we just configured with ssmtp above.
Postfix example.
mynetworks =,

smtpd_sender_restrictions =
    ...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:
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.


It is also possible to use TLS with ssmtp, which is very nice. Check the man pages for this.
Do not trust the authors words! POC, tests and experience is key

Copyright LinuxLasse.net 2009 - 2024 All Rights Reserved.

Valid HTML 4.01 Strict Valid CSS!