A Simple PHP HTML Mail function with out SMTP credentials.
-
- Chandra Sekar M
- 02-Aug-2024-05:24:52 PM
- Page Visitors : 61
A Simple PHP HTML Mail function with out SMTP credentials. The Mail() function allows to trigger emails directly from script.
Syntax : mail(to,subject,message,headers,parameters);
To Send a HTML email using PHP Script
<?php $to = $email; $from = 'support@domainname.com'; $subject = 'Registration confirmation with Website'; $headers = "From: " . strip_tags($from) . " "; $headers .= "Reply-To: ". strip_tags($from) . " "; $headers .= "MIME-Version: 1.0 "; $headers .= "Content-Type: text/html; charset=ISO-8859-1 "; $message = '<html><body>'; $message .= '<table width="100%"; rules="all" style="border:1px solid #3A5896;" cellpadding="10">'; $message .= "<tr><td><img src=' http://domainname.com/master/img/login-logo.png' alt='Customer Statz' /></td></tr>"; $message .= "<tr><td colspan=2>Dear ".$f_name.",<br /><br />We thank you for join with domainname, Now you can login with your account details.</td></tr>"; $message .= "<tr><td colspan=2 font='colr:#999999;'>Email:".$email."</td></tr>"; $message .= "<tr><td colspan=2 font='colr:#999999;'>Password:".$password."</td></tr>"; $message .= "</table>"; $message .= '<br/><br/><a style="margin-top:20px" href="http://domainname.com/login.php">Click here to login with domainname.</a>'; $message .= "</body></html>"; mail($to, $subject, $message, $headers); ?>
Sign up for free and be the first to get notified about new posts.