I have used PHPmailer to send email to users upon registering to the site. Now, everything works as should, however, I find myself doing painstaking work adding the HTML elements in.
Here's an example piece of HTML code:
<p>This is a paragraph</p>
<span>Now this is important!</span>
<h4>Uh Oh!</h5>
Now in the PHP class, I would have to ''
and .
after each HTML element, so for example:
'<p>'.
'</p>'.
'<span>'.
'<h4>'.
'</h4>';
As you could imagine, doing this for a whole XHTML page, can take a very long time. I was wondering if there's a method that's quicker and more efficient than my technique.
Here's my entire PHP class that includes the HTML elements:
$mail->Body =
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'.
'<html xmlns="http://www.w3.org/1999/xhtml">'.
'<head>'.
' <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'.
' <title>Demystifying Email Design</title>'.
' <link href="https://fonts.googleapis.com/css?family=Dosis" rel="stylesheet" type="text/css"/>'.
' <meta name="viewport" content="width=device-width, initial-scale=1.0"/>'.
'</head>'.
'<body style="margin: 0; padding: 0;">'.
' <table border="0" cellpadding="0" cellspacing="0" width="100%">'.
'<tr>'.
'<td>'.
'<table align="center" border="0" cellpadding="0" cellspacing="0" width="600" style="border-collapse: collapse;">'.
'<tr>'.
'<td align="center" bgcolor="#70bbd9" style="padding: 40px 0 30px 0;">
<img src="http://tutsplus.github.io/build-an-html-email-template-from-scratch/images/h1.gif" alt="Creating Email Magic" width="300" height="230" style="display: block;" />'.
'</td>'.
'</tr>'.
'<tr>'.
'<td bgcolor="#ffffff" style="padding: 40px 30px 40px 30px; font-family: "Dosis", sans-serif;">'.
'<table border="0" cellpadding="0" cellspacing="0" width="100%">'.
'<tr>'.
'<td>';
echo "Hello there hero!";
'</td>'.
'</tr>'.
'<tr>'.
'<td style="padding: 20px 0 30px 0;">';
echo " Cheesy heading, we know. BUT! Thanks for signing up with us! We just need you to do one, tiny little thing! You see that button down there? The big yellow one? We're going to need you to click that.. Seems daunting, but trust us. Once you do, you'll get access to all our websites features! Easy right? So go ahead, what are you waiting for?";
'</td>'.
'</tr>'.
'<tr>'.
'<td>'.
'<table border="0" cellpadding="0" cellspacing="0" width="100%">'.
'<tr>'.
'<td width="260" valign="top">'.
'<tr>'.
'<td>'.
'<div class="button">';
echo "Verify Account!";
'</div>'.
'</td>'.
'</tr>'.
'</table>';