help with mail() function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ja03
Forum Newbie
Posts: 1
Joined: Wed Dec 25, 2002 4:15 pm

help with mail() function

Post by ja03 »

Hi guys,

I'm new to PHP (but have been doing much research) and have been experiencing a problem with the mail() function. When I run the following simple code on my "localhost" computer, there is no problem. But when I run it on a hosted server (windows 2000), it gives me a "server error" message. I spoke to tech support at the hosting company and he tells me its a code problem and that all windows servers are different. I know they run php and allow us to use the mail() function. I don't understand what the problem is.

<?
$to = "myemailaddress@domain.com";
$subject = "testing PHP mail";
$msg = "test";
mail("$to", "$subject", "$msg");
echo "finished!";
?>

Thanks in advance,
Jon
evilcoder
Forum Contributor
Posts: 345
Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia

Post by evilcoder »

Try this:

<?php

$to = "The email your sending to.";
$subject = "testing PHP mail";
$msg = "test";
$femail = "Your Email address";

mail("$to","$subject","$msg","From:$femail");
echo "Finished!"
?>
Post Reply