Its very easy to send an email using php we just need to use integrated function of php 'mail'
$to = variable that holds the address where emails has to be sent.
$subject = variable to hold the subject of email
$body = this is the body of the email, we can send html email too by defining headers in our email function.
$headers = this variable is responsible to define metadata of our email. i.e(from, reply-to, auto-responder)
-> example of simple email:
mail("receiver@emailadd.com", "this is the body of Subject", "this is body of email", "From: sender@emailadd.com);
?>
->here is another example to send HTML Email by dfining headers and using variables
<?php
$to = "receiver@emailadd.com"
$sub = "This is the Subject of Body";
$body = This is First Line<br/>This is Second Line <b>some thing bold</b>";
$from = "sender@emailadd.com";
$headers = "From: $from" . "\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to, $sub, $body, $headers);
?>
in above functions we define variables to be used in mail function and also define headers that tells the mail function about the property of email body and some other meta information.
No comments:
Post a Comment