Ad Code

Ticker

6/recent/ticker-posts

send html mail in php

Send PHP mail

mail() function :- 

Sending email message very simple on the website, for example, sending the welcome email when users are signup on your website and sending newsletters to your registered user and getting feedback or comment on your website and other much more.
You can use a built-in PHP mail() function for sending mail which is simple or HTML mail. The mail sent to one or more recipient at a time of your PHP application.
The syntax for mail() function:-

mail(to, subject, message, headers, parameter);

to:- In this store the recipient email.
subject:- Subject for the sending mail, and it does not have newline parameter.
message:- This section writes your message to be sent to the recipient. In simple mail format not exceed 70 characters.
headers:- This adds your email extra headers such as 'From', 'CC' and 'BCC'. The additional headers should have separated with \r\n.
parameter:- This is used to pass an additional parameter in mail.

Sending simple mail:-

<?php

$to="recipient email address";

$subject="subject of the sent mail";

$messages="write youe mail message here";

if(mail($to, $subject, $messages))

{

    echo "Email sent";

}

else

{

    echo "Email is unable to sent";

}
?>


Sending HTML mail:-

Sending HTML mail procedure is same but in the html mail use additional header and in message part use the html tag and styles for mail.

<?php

$to="recipient email address";

$subject="subject of the sent mail";

$from_email="your mail or webmail email id";
$headers="MIME-Version: 1.0" . "\r\n";
$headers.="Content-type: text/html; charset=iso-8859-1" . "\r\n";
$headers .= "From: ".$from_email."\r\n".
    "Reply-To: ".$from_email."\r\n";
$messages = "<html><body>";
$messages .= "<h1 style='color:green;'>Thanks for mail</h1>";
$messages .= "<p>Your message write here ....</p>";
$messages .= "</body></html>";

if(mail($to, $subject, $messages, $headers))

{

    echo "Email sent";

}

else

{

    echo "Email is unable to sent";

}

?>

Post a Comment

1 Comments

  1. This was informative. Has anyone heard about Rank Tracker Tool? Any experiences? The link is http://www.ranktrackertool.com.

    ReplyDelete

Ad Code