Send Mail using Php


Now Todays we will lean “send mail using php”. It simple method to send email using php codes. There are some field require to process this php script. These are like as To, Subject, Message, From. You can also extend all other option its depend on your requiremet. This guide to beginner for “send mail using php”.

Send Mail using Php Step 1:

Create File with name sendmail.php and paste above codes in it.

<?php
$to = "toaddress@mailservername.com";
$subject = "Just a test mail";
$message = "Just training on php";
$from = "fromaddress@mailservername.com";

Now we define the parameters to,suject,message and header containing from and reply address. In script header is the area where user set the from address, reply to address, cc address, etc.

/* To send HTML mail, you can set the Content-type header. */

$headers1 = "MIME-Version: 1.0\r\n";
$headers1 .= "Content-type: text/html; charset=iso-8859-1\r\n";

/* additional headers */
$headers1 .= "To: ".$to."\r\n";
$headers1 .= "From: ".$from."\r\n";
$headers1 .= "Reply-To: ".$from."\r\n";
?>

Send Mail using Php Step 2:
 
Now send the mail through Php Api

<?php
mail($to, $subject, $message, $headers);
?>
 You have done Send Mail using Php !
Share:

No comments:

Post a Comment