Sending e-mails in HTML format using PHP simple mail function.

No votes yet.
Please wait...

Hello, our fellow developers. We are back with yet another interesting case. Sending emails in attractive formats which would influence and enhances your brand identity seems a typical task to do but reality is totally different. So here we are sharing you the insights of how to send awesome formatted Emails through your websites and campaigns.

Sending email in HTML format is very impressive for the customers and very easy for the people to keep the data in proper format.

Not only sending mail helps but sending an acknowledge email to the customer in formatted form shows that how professional you are. This format has a wide variety of use from subscription emails to lead generation campaigns it helps the administrators to attract the audiences and remain in their mailboxes for a very long time.

Let’s us start the exploring the chances of influencing through HTML Emails.

Now let us show you the power of Good Email.

mail.php

<?php

if($_POST)

{

$name =’PHP Hurdles’;

$email =’help@phphurdles.com’;

$contact= ‘+91-9718991797’;

$text= “Write your message here.”;

$Message = ‘<table width=”600″ border=”0″ align=”center” cellpadding=”0″ cellspacing=”0″>

<tr><td style=”padding: 20px; border: 1px solid #c3c3c3; position: relative;”><table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”0″>

<tr><td align=”left” style=”background: #fff; padding: 15px 0px;” bgcolor=”#120001″><img src=”http://phphurdles.com/wp-content/uploads/2017/01/blog.png” width=”200px;” alt=”PHP Hurdles” /></td</tr>

<tr><td height=”50″><hr style=”width: 100%;” color=”#c3c3c3″ size=”1″ /></td></tr>

<tr><td style=”font-family: \’Helvetica Neue\’, \’Segoe UI\’, Helvetica, Arial, \’Lucida Grande\’, sans-serif; font-size: 18px; color: #666666;”>Hi Team,</td></tr>

<tr><td style=”font-family: \’Helvetica Neue\’, \’Segoe UI\’, Helvetica, Arial, \’Lucida Grande\’, sans-serif; font-size: 18px; color: #666666;”>Here is the new query to the landing page.</td></tr>

<tr><td>&nbsp;</td></tr>

<tr><td style=”font-family: \’Helvetica Neue\’, \’Segoe UI\’, Helvetica, Arial, \’Lucida Grande\’, sans-serif; font-size: 18px; color: #666666;”>Name : ‘.$name.'</td></tr>

<tr><td style=”font-family: \’Helvetica Neue\’, \’Segoe UI\’, Helvetica, Arial, \’Lucida Grande\’, sans-serif; font-size: 18px; color: #666666;”>Email : ‘.$email.'</td></tr>

<tr><td style=”font-family: \’Helvetica Neue\’, \’Segoe UI\’, Helvetica, Arial, \’Lucida Grande\’, sans-serif; font-size: 18px; color: #666666;”>Mobile : ‘.$mobile.'</td></tr>

<tr><td style=”font-family: \’Helvetica Neue\’, \’Segoe UI\’, Helvetica, Arial, \’Lucida Grande\’, sans-serif; font-size: 18px; color: #666666;”>Message: ‘.$text.'</td></tr>

<tr><td style=”font-family: \’Helvetica Neue\’, \’Segoe UI\’, Helvetica, Arial, \’Lucida Grande\’, sans-serif; font-size: 18px; color: #666666;;”></td></tr>

<tr><td>&nbsp;</td></tr>

</table>’;

// To send HTML mail, the Content-type header must be set

$headers  = ‘MIME-Version: 1.0’ . “\r\n”;

$headers .= ‘Content-type: text/html; charset=iso-8859-1’ . “\r\n”;

$to = “mangleshup@gmail.com”;

$sub = “Customer query”;

// Additional headers

$headers .= “From: $email” . “\r\n”;

$headers .= ‘cc: saurabh@phphurbles.com’ . “\r\n”;

$headers .= ‘Bcc: manglesh@phphurbles.com’ . “\r\n”;

//Multiple BCC, same as CC above;

//$headers .= ‘Bcc: myboss3@example.com, myboss4@example.com’ . “\r\n”;

$Mail = mail($to, $sub, $Message, $headers);

if($Mail)

{

$Acknowledge = ‘<table width=”600″ border=”0″ align=”center” cellpadding=”0″ cellspacing=”0″>

<tr><td style=”padding: 20px; border: 1px solid #c3c3c3; position: relative;”><table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”0″>

<tr><td align=”left” style=”background: #fff; padding: 15px 0px;” bgcolor=”#120001″><img src=”http://phphurdles.com/wp-content/uploads/2017/01/blog.png” width=”200px;” alt=”PHP Hurdles” /></td></tr>

<tr><td height=”50″><hr style=”width: 100%;” color=”#c3c3c3″ size=”1″ /></td></tr>

<tr><td style=”font-family: \’Helvetica Neue\’, \’Segoe UI\’, Helvetica, Arial, \’Lucida Grande\’, sans-serif; font-size: 18px; color: #666666;”>Hi ‘.$name.'</td></tr>

<tr><td style=”font-family: \’Helvetica Neue\’, \’Segoe UI\’, Helvetica, Arial, \’Lucida Grande\’, sans-serif; font-size: 18px; color: #666666;”>Thank you! our team will contact you soon.</td></tr>

<tr><td>&nbsp;</td></tr>

</table>’;

$headers  = ‘MIME-Version: 1.0’ . “\r\n”;

$headers .= ‘Content-type: text/html; charset=iso-8859-1’ . “\r\n”;

$subject = “Acknowledge email”;

// Additional headers

$headers .= “From: $to” . “\r\n”;

$headers .= ‘cc: saurabh@phphurbles.com’ . “\r\n”;

$headers .= ‘Bcc: manglesh@phphurbles.com’ . “\r\n”;

$acknowledgeemail = mail($email, $subject, $Acknowledge, $headers);

if($acknowledgeemail)

{

echo “Thank you! we will contact you soon.”;

}  }

else{

echo “Sorry! few technical problem caused.”;

}

}

?>

We are pretty sure that this article will help you in customizing your email format and next time you will send the attractive emails to your audiences.

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve : *
19 − 14 =