View Full Version : PHP Email Testing using XAMPP

08-21-2008, 09:41 AM
ok so I am using XAMPP and trying to send an email to myself here is my code:

$name = $_POST['name'];
$email = $_POST['email'];
$body = $_POST['body'];
if ($name != "" AND $email != "" AND $body != "") {
$sendto = "myemail@blah.com";
$subject = "Email from site!";

$message = "This is a message from your site
From: $name
Email: $email
Message: $body";
// send the mail
mail("$sendto", "$subject", "$message","mosh");
echo "Your message was sent";
?><form method="post" name="mailform" action="<?=$_SERVER['PHP_SELF'] ?>">

<table width="200" border="0" cellspacing="0">
<td width="62">Name:</td>
<td width="134">
<input name="name" type="text" id="name">
<td><input name="email" type="text" id="email"></td>
<td valign="top">Message:</td>
<td><textarea name="body" cols="45" rows="10"></textarea></td>
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit2" value="Reset">

I dont think there is anything wrong with the code snippet because i got it from a reliable source: http://www.dreamincode.net/code/browse.php?cid=1

but here is the error i keep getting when i try to run it:

Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in

I tried messing with the php.ini file but that got me no where (probably cuz i have no idea what to do with it)

Any help with this problem would be very appreciated. Thank You in advance!

08-21-2008, 09:57 PM
I'm no whiz with the mail() function. But Its because in php.ini, around line 753. You've got a variable called "sendmail_from", its probably set to "localhost", give that an email. For example. My email is jeremyfifty9 [at] gmail [dot] com. SO I'd put that in. Below is an attachment of what the line probably is defaulted to.
Also just to make your code a bit shorter, you can change:

if ($name != "" AND $email != "" AND $body != "") {


if ($name != "" && $email != "" && $body != "") {


mail("$sendto", "$subject", "$message","mosh");


08-21-2008, 10:10 PM
I use xampp also on a vista box. You need to install a mail server, and depending on your isp there are different configurations.

I thought about it some more and remember a little more about when I installed xampp.

If you're just using it for local development like me and are not hosting a site then you'll need an e-mail address. That's were it depends on your isp. You can configure it to work with a free web mail service but gmail is the only one that I remember. Yahoo is a no go. I'm a noob so hopefully my recollection will aid others in helping you resolve your problem.

Good luck,