Is it OK to use a single SMTP server mail.domain1.com for authenticated mail sending from multiple originating domains other than domain1.com using ssmtp?
If yes, what happens with FROM, SENDER, and REPLY-TO headers when an end-user fills a contact form on a web server domain-xy.com, if I setup ssmtp with FromLineOverride=yes?
What about spam tagging/filtering in this scenario?
![](../../users/profiles/157386.webp)
- 153
- 1
- 5
2 Answers
Yes, I've done it and it works fine. I have a tutorial which covers SSMTP here, which I've copied the key parts of below.
The application sending the email needs to set the headers properly. The email server that SSMTP uses needs to be configured for those domains. Remember SSMTP doesn't send mail directly to the target server, it sends it to an email server you control which does everything else - at least as far as I know and that's how I use it.
Download my config
You can download my configurations from this page
Tutorial Copy and Paste
Here's the key parts of my tutorial. I did this over a year ago and don't remember the details, that's why I wrote it down.
SSMTP installation
yum install ssmtp
usermod -a -G mail (username) (adds you to the mail group)
alternatives --config mta (choose SSMTP)
sendmail -V (validate that it says something like "sSMTP 2.61 (Not sendmail at all)"
cp /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf.orig (this backs up the original config)
cp etc/ssmtp/revaliases /etc/ssmtp/revaliases.orig
RevAliases
Set up your file permissions for ssmtp – you probably want the same for revaliases.conf
sudo chown root:mail /etc/ssmtp/ssmtp.conf
sudo chmod 640 /etc/ssmtp/ssmtp.conf
Now set up the ssmtp.ini
ssmtp.conf
vi /etc/ssmtp/ssmtp.conf (set up as per guide)
Make sure this following is configured
root=postmaster
mailhub=mail.yourdomain.com:587
Hostname=localhost
FromLineOverride=YES
AuthUser=username@yourdomain.com
AuthPass=YourPassWord
UseSTARTTLS=YES
Set up the reverse aliases
vi /etc/ssmtp/revaliases
Add the following, set up for your own details of course
root:username@yourdomain.com:mail.yourdomain.com:587
Rewriting
Now set up how email is rewritten
vi /root/.muttrc
Include this information
set envelope_from=yes
set from="username@gmail.com"
set realname="Prefer From Display"
Testing
To test this use a command like this
echo "Testing SSMTP." | mail -s 'SSMTP Test' mail@example.com
![](../../users/profiles/306795.webp)
- 30,383
- 6
- 47
- 77
when an end-user fills a contact form on a web server
Should absolutely not change the from address, you must send email only from domains you either control, manage, or have permission to send. The filled in from field should only change the reply-to field.
![](../../users/profiles/200560.webp)
- 7,636
- 3
- 25
- 55
-
1I'm trying to change the FROM address, but to one of the other domains I manage and live on the same server as the original ssmtp host. I plan to verify all domains on that host in Mailgun, and use Mailgun to send from the original ssmtp host (also verified). – steakoverflow Nov 26 '17 at 06:26