Wednesday, November 26, 2014

how to send mail in php from localhost?

In previous chapter you got idea to configure your XAMPP. If you've configured then move to code to send mail and if not then configure at first. click here to configure.
Now it's time to write code in order to send mail. Below is the code to send mail using php:


$to = "";
$subject = "HTML email using PHP";

$message = "
<title>HTML email</title>
<p>This is an HTML Email send using php mail function.</p>

// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

// More headers
$headers .= 'From: <>' . "\r\n";

echo "success";
echo "fail";