elepil
asked on
Apache/PHP sendmail FROM issue
I've gotten my local Apache server and PHP to work with sendmail. But there is one problem. First, here is my PHP script:
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.
<?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:
force_sender=no-reply@localhost.com
I can't see anything else I can modify that might affect the FROM field. Anyone have any advice? Thanks.
ASKER
I'm actually using Google's gmail server. Here's the info I put in the sendmail.ini:
I have no local mail server.
smtp_server=smtp.gmail.com
smtp_port=587
auth_username=your_email_address@gmail.com
auth_password=your_email_password
force_sender=your_email_address@gmail.com
I have no local mail server.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
To sunnysunny. No, it did not work, but thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the help!
Thanks for the points and thanks for using E-E! ~Ray
I'll see if I have an example that designates the "From" and if I can find one, I'll post it here.