Monday, November 18, 2019
Home » PHP » Send email script in php

Send email script in php

Send email script in php – use the mail() for email in php first parameter is To,Subject,Message these are required parameters and also two optional headers and parameters

to = required
subject = required
message = required

Simple Example

$to = "";
$subject ="Mail Test";
$message = "Hi testing mail..";
// Send

HTML mail format in PHP

$mesg   = '<html><body>';
$mesg .= '<div style ="border:1px solid #268618;width:600px;"><table cellpadding="10" width="600px;">';
$mesg .= "<tr style='background: #eee;'><td colspan='2'>Hi,</td></tr>";
$mesg .= "<tr><td colspan='2'>.$message.</td></tr>";
$mesg .= "<tr><td colspan='2'> &nbsp;</td></tr>";
$mesg .= "<tr><td colspan='2'> - Thanks</td></tr>";
$mesg .= "</table></div>";
$mesg .= '</body></html>';
$header  = "From: $fromrn" ;            
$header .= "MIME-Version: 1.0n" . "Content-type: text/html; charset=iso-8859-1n" ;      
$res = mail($to, $subject, $mesg, $header);