Jump to content

Sending email message...


Guest askjames01

Recommended Posts

Guest askjames01
I tried sending email messages without using the form...
fortunately there was no error but the problem was i can't see the message in my inbox..

these are the codes:
[code]
<?php
$ip = $_SERVER['REMOTE_ADDR'];
echo 'your I.P. address is: ';
echo $ip;

if($ip != '203.76.211.121')
       echo "ip not equal!\n";
else {
                $recepient = "webmaster@domain_name.com";
                $subject = "You have Guest!";

    $contents = "Your ip is:" . $ip;
                
                $headers = "Reply-to: webmaster@domain_name.com\n";
                mail($recepient, $subject, $contents, "From: webmaster@domain_name.com");

    }
        }
?>
[/code]

I wonder what was the problem with my codes or what do you think is lacking?

-/james
Link to comment
https://forums.phpfreaks.com/topic/4811-sending-email-message/
Share on other sites

You have:
[code]<?php
                $headers = "Reply-to: webmaster@domain_name.com\n";
                mail($recepient, $subject, $contents, "From: webmaster@domain_name.com");
?>[/code]
You create the $headers variable, but you don't use it. The "From:" header should be terminated with a new line character. You might have to include the fifth parameter on the mail() line.

[code]<?php
               $headers = "From: webmaster@domain_name.com\n";
               $headers .= "Reply-to: webmaster@domain_name.com\n";
               $p5 = '-f webmaster@domain_name.com';
                mail($recepient, $subject, $contents, $headers,$p5);
?>[/code]

The fifth parameter is almost always needed when sending to a Hotmail, Yahoo, Gmail, or AOL address.

Ken
Link to comment
https://forums.phpfreaks.com/topic/4811-sending-email-message/#findComment-16990
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.