I've gotten my local Apache server and PHP to work with sendmail. But there is one problem. First, here is my PHP script:
<?php$to = "myEmail@gmail.com"; // ***** LET'S SAY THIS IS MY EMAIL ADDRESS$subject = "Testing from local PHP at " . strftime("%T", time());$message = "Hello, PHP world!";$from = "no-reply@localhost"; // ***** THIS IS THE 'FROM' EMAIL ADDRESS I SPECIFIED$headers = "From: {$from}";/** * The mail() function returns true or false depending on whether it was successful * in sending it. */$result = mail($to, $subject, $message, $headers);echo $result ? "Sent" : "Error";?>
The email succeeds, but the FROM always has myEmail@gmail.com, not the no-reply@localhost I specified. Can anyone tell me how to correct this? There aren't really much to configure in sendmail.ini, and I even did:
I can't see anything else I can modify that might affect the FROM field. Anyone have any advice? Thanks.
Apache Web ServerPHPEmail Servers
Last Comment
Ray Paseur
8/22/2022 - Mon
Ray Paseur
Is this on a hosted server? If so, your service provider might be changing your email headers. Not sure about this -- email is amazingly simple in concept but amazingly complex in implementation.
I'll see if I have an example that designates the "From" and if I can find one, I'll post it here.
elepil
ASKER
I'm actually using Google's gmail server. Here's the info I put in the sendmail.ini:
I'll see if I have an example that designates the "From" and if I can find one, I'll post it here.