web 2.0

How to use PHP & Send Email HTML Format

How to use PHP & Send Email HTML Format This the tutorial/example a scripts how to use PHP and send mail/email HTML Format from php Scirpt.

ShotDev Focus:
- PHP & Send Mail (HTML Format)

Example

php_sendmail_html.php


<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<?
$strTo = "member@shotdev.com";
$strSubject = "Test sending mail";
$strHeader = "Content-type: text/html; charset=windows-874\n"; // or UTF-8 //
$strHeader .= "From: Mr.Weerachai Nukitram<webmaster@shotdev.com>\nReply-To: shotdev@hotmail.com";
$strVar = "My Message";
$strMessage = "
<h1>My Message</h1><br>
<table width='285' border='1'>
<tr>
<td><div align='center'><strong>My Message </strong></div></td>
<td><div align='center'><font color='red'>My Message</font></div></td>
<td><div align='center'><font size='2'>My Message</font></div></td>
</tr>
<tr>
<td><div align='center'>My Message</div></td>
<td><div align='center'>My Message</div></td>
<td><div align='center'>My Message</div></td>
</tr>
<tr>
<td><div align='center'>".$strVar."</div></td>
<td><div align='center'>".$strVar."</div></td>
<td><div align='center'>".$strVar."</div></td>
</tr>
</table>";

$flgSend = @mail($strTo,$strSubject,$strMessage,$strHeader);  // @ = No Show Error //
if($flgSend)
{
echo "Mail send completed.";
}
else
{
echo "Cannot send mail.";
}
?>
</body>
</html>

Create a php file and save to path root-path/myphp/

Run
http://localhost/myphp/php_sendmail_html.php

Screenshot

PHP Send Mail (HTML Format)

PHP Send Mail (HTML Format)

.
.
.

Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 1.00 out of 10)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.