PHP Mailing

How can I use php to send mail?

Explanation

Follow the steps to do it yourself
Step 1:
Its realy simple to send mail using php.
First define the parameters to,suject,message and header containing from and reply address
<?php
$to = "toaddress@mailservername.com";
$subject = "Just a test mail";
$message = "Just training on php";
$from = "fromaddress@mailservername.com";
//Header is the portinn where we will set the from address, reply to address, cc address, etc....
//The display of address we see on the top (from,to,replyto) portion of the composer will be based on the header we set

/* To send HTML mail, you can set the Content-type header. */
$headers1 = "MIME-Version: 1.0rn";
$headers1 .= "Content-type: text/html; charset=iso-8859-1rn";
/* additional headers */
$headers1 .= "To: ".$to."rn";
$headers1 .= "From: ".$from."rn";
$headers1 .= "Reply-To: ".$from."rn";
?>

Step 2:
Now we send the mail using php api
<?php
mail($to, $subject, $message, $headers);
?>

PHP Topics


Ask Questions

Ask Question