<?php
$subject="testmail";
$message="this is test mail from php";
$to="****@****.com";//for an example
$status=mail($to,$subject,$message);

if ($status)
{
	echo "Mail successfully Send";
}

?>

when i execute this script, it displays the following error., why this error?

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

Recommended Answers

All 3 Replies

Try this:

/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

/* additional headers */
$headers .= "To: Mary <mary@example.com>, Kelly <kelly@example.com>\r\n";
$headers .= "From: Birthday Reminder <birthday@example.com>\r\n";
$headers .= "Cc: birthdayarchive@example.com\r\n";
$headers .= "Bcc: birthdaycheck@example.com\r\n";

/* and now mail it */
mail($to, $subject, $message, $headers);

or check this for your error:
http://www.w3schools.com/PHP/php_ref_mail.asp

Change your mail command to
$status=mail($to,$subject,$message,"From:<from@email.com>");
This will show the email coming from from@email.com but you can change that to what you want.
Regards,
Sam Rudge

Try this and see if it works, but you may have to modify it to reflect your form fields:

$subject="Name: ".$name."
Email: ".$email."
Message: ".$message."
";
$subject = stripslashes($subject);
mail("sales@yoursite.com","Contact Form Submitted",$subject,"From: Test mail from php");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.