0

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

ultramizer
  • 31
  • 8

3 Answers3

1

I could not resolve this issue. If anyone else is having this issue, the only thing you can try is FromLineOverride=YES if that's not working, you're pretty much screwed.

I for one, has changed over from sSMTP to regular sendmail, which is working like a charm.

Cheers

ultramizer
  • 31
  • 8
0

Try the following adding this to your php script:

$email_message = "Something here";
$email_subject = "a subject";
$email_recipient = "test@example.com";
$email_headers = "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();
mail($email_recipient, $email_subject, $email_message, $email_headers);
DannySMc
  • 27
  • 8
  • of course changing it to suit your needs, email recipient, content etc. – DannySMc Mar 09 '15 at 14:49
  • Ok, i have tried the following: See my Edit on the main entry, as i cannot post code markdown here in comments, or i am just too stupid... – ultramizer Mar 09 '15 at 15:40
  • Ahh I have seen and no you can't post it in a comment, I will have a look as my work has a set up one and will see if they can help you! Sorry my suggestion couldn't help you! – DannySMc Mar 11 '15 at 09:58
0

sSMTP is a popular choice as a simple sendmail replacement for php mail relay in docker containers. If anyone comes across this question because they are using sMTP with Docker containers and cannot get the from header to appear correct in php emails then I recommend moving to msmtp. It is easy to install and use in the standard php docker images.

paj
  • 1,177
  • 16
  • 33