0

When I send a message using the code below, it sends fine. But if I change the $headers to have 'From: Firstname Lastname' it doesn't send for some reason. How do I add my name to the header instead of the email address?

  $subject = 'Test message';
  $headers = 'From: mymail@mydomain.com' . "\r\n" .
     'Reply-To: mymail@mydomain.com' . "\r\n" .
     'X-Mailer: PHP/' . phpversion();
  mail($to, $subject, $themessage, $headers);
dlofrodloh
  • 1,728
  • 3
  • 23
  • 44

1 Answers1

1

Some (most, I think) email clients check the From field to make sure the domain is the same as the domain that sent the message. This is to prevent spoofing. Try something like "From: Firstname Lastname <name@domain.com>"

Kluny
  • 189
  • 3
  • 17