I am having issues with my sSMTP setup. It is working fine for sending e-mails, i am receiving them, but it completely ignores my "From: " header! The from address is always "http@mydomain.com" if sSMPT is triggered through the php mail function or "root@mydomain.com" if triggered through an ssh session logged in as root. So i am thinking it always uses the current user and uses that as the "From: " address.
Now i know that you can set FromLineOverride=YES
to allow to use your own From address, i have set that in my sSMPT config, but that doesn't work. It's just ignoring that completely.
Here's my Setup:
sSMTP config:
# The user that gets all the mails (UID < 1000, usually the admin)
root=info@mydomain.com
# The mail server (where the mail is sent to), both port 465 or 587 should be acceptable
mailhub=mydomain.com:587
# The address where the mail appears to come from for user authentication.
# rewriteDomain=info@mydomain.com
# i have tried this function above in different ways, doesnt change anything...
# The full hostname
hostname=mydomain.com
# Use SSL/TLS before starting negotiation
UseTLS=Yes
UseSTARTTLS=Yes
# Username/Password
AuthUser=info
AuthPass=password
# Email 'From header's can override the default domain?
FromLineOverride=YES
php Script to test the Mail function:
<?PHP
$empfaenger = "user@gmail.com";
$betreff = "Testing Mailserver";
$text = "It seems to work";
$extra = "From:Info <info@mydomain.com>\r\n";
// i have tried "From: Info..." with a space inbetween From: and Info.
if(mail($empfaenger, $betreff, $text, $extra)) {
echo 'E-Mail sent';
}
?>
So i get no errors, the mail get's through, the Mailserver is running on my local machine and sees the mails, and i can confirm the mailserver does not change the address it's sent from, he just takes what he gets from sSMTP.
What am i doing wrong?
Cheers
Edit: Tried the following as suggested by DannySMc
<?PHP
$empfaenger = "user@gmail.com";
$betreff = "Testing Mailserver";
$text = "Seems to work";
$extra = "From: no-reply@example.com \r\n".
'Reply-To: no-reply@example.com '."\r\n" .
"Return-Path: no-reply@example.com\r\n" .
'X-Mailer: PHP/' . phpversion();
if(mail($empfaenger, $betreff, $text, $extra)) {
echo 'E-Mail versendet';
}
?>
Still does not work. I still see the mail coming from http@mydomain.com