3

I am sending emails from my server via PHP > postfix > Sendgrid. In PHP, I set the From: header to my noreply@domain.com. However, the email will always have Apache@mail.domain.com in the From header.

New to sending emails from the server, what configuration files should I look at? Or how can I debug this?

I am setting the headers like this in PHP:

$headers = "From: ".$from."\r\n";
$headers = "Reply-To: ".$from."\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
nathancahill
  • 10,452
  • 9
  • 51
  • 91
  • Are you running [`sendmail`](http://www.postfix.org/sendmail.1.html) directly? Or are you submitting to an SMTP host? – sarnold Jun 29 '12 at 02:26
  • Well, that's embarrassing. Figured it out. I was appending to the headers in PHP with `$headers .= "From: ".$from."\r\n";` One line didn't have the `.=` and was overwriting all previous headers. – nathancahill Jun 29 '12 at 02:31
  • 3
    Nice catch. Can you [edit] the question to include the offending code and provide an answer that fixes it? :) – sarnold Jun 29 '12 at 02:38

1 Answers1

0

The problem was that one of the $headers .= lines didn't have a .= and was overwriting the previous headers. Easy to miss I guess.

nathancahill
  • 10,452
  • 9
  • 51
  • 91