PHPMailer doesn't send email - php

I would like to send and email trough the PHPMailer class. The code doesn't launch any error but the method $mail -> Send() returns false and I don't know why.
$emailList looks like:
Array(
[0] => mate80#yopmail.com
[1] => mate81#yopmail.com)
The ./html/mail/index.html looks like:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- If you delete this meta tag, the ground will open and swallow you. -->
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>TeamEQ</title><style type="text/css">img {max-width: 100%;}body {-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; width: 100% !important; height: 100%;}#media only screen and (max-width: 600px) { a[class="btn"] {
display: block !important; margin-bottom: 10px !important; background-image: none !important; margin-right: 0 !important; }div[class="column"] {
width: auto !important; float: none !important; }table.social div[class="column"] { width: auto !important;}}
<!-- HEADER -->
<table class="head-wrap" bgcolor="#999999" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; width: 100%; background: white; margin: 0; padding: 0;">
<tr style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;">
<td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;"></td>
<td class="header container" align="" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; display: block !important; max-width: 600px !important; clear: both !important; margin: 0 auto; padding: 0;">
<!-- /content -->
<div class="content" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; max-width: 600px; display: block; margin: 0 auto; padding: 15px;">
<table style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; width: 100%; margin: 0; padding: 0;">
<tr style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;">
<td class="logo" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; text-align: center; margin: 0; padding: 15px;" align="center"><img src="{#urlToLogo}" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; max-width: 100%; margin: 0; padding: 0;" /></td>
</tr>
</table>
</div>
<!-- /content -->
</td>
<td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;"></td>
</tr>
</table>
<!-- /HEADER -->
<!-- BODY -->
<table class="body-wrap" bgcolor="" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; width: 100%; margin: 0; padding: 0;">
<tr style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;">
<td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;"></td>
<td class="container" align="" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; display: block !important; max-width: 600px !important; clear: both !important; margin: 0 auto; padding: 0;">
<!-- content -->
<div class="content" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; max-width: 600px; display: block; margin: 0 auto; padding: 15px;">
<table style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; width: 100%; margin: 0; padding: 0;">
<tr style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;">
<td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;">
<h1 style="font-family: 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; line-height: 1.1; color: #000; font-weight: 200; font-size: 44px; margin: 0 0 15px; padding: 0;">Bienvenid#!</h1>
<p class="lead" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-weight: normal; font-size: 17px; line-height: 1.6; margin: 0 0 10px; padding: 0;"></p>
<!-- A Real Hero (and a real human being) -->
<!--<p><img class="quote" src="https://s-media-cache-ak0.pinimg.com/236x/ad/5c/92/ad5c92c02290a4cb06dbcda734dc09da.jpg" /></p>-->
<p style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-weight: normal; font-size: 14px; line-height: 1.6; margin: 0 0 10px; padding: 0;">Has sido invitad# al equipo {#teamName} por parte de {#teamLeader}.</p>
<p style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-weight: normal; font-size: 14px; line-height: 1.6; margin: 0 0 10px; padding: 0;">Para completar el registro pulsa aquí, o copia el siguiente enlace en tu navegador:</p>
<!--
#env teameq-frontend.cloudapp.net variable de entorno.
Cambiar en la rama env las variables de entorno para el link de retorno del mail de invitación de usuarios.
-->
<p style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-weight: normal; font-size: 14px; line-height: 1.6; margin: 0 0 10px; padding: 0;">http://app.teameq.net/#/signup/teammate/{#teamId}/{#invitationalToken}</p>
<br style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;" />
<p style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-weight: normal; font-size: 14px; line-height: 1.6; margin: 0 0 10px; padding: 0;">Gracias por tu atención, estamos ilusionados por ver cómo TeamEQ mejora tu entorno laboral!</p>
<!-- /hero -->
</td>
</tr>
</table>
</div>
</td>
<td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;"></td>
</tr>
</table>
<!-- /BODY -->
The code updated with comments below is:
$teamMembers = $bbdd -> getTeam($teamId);
for($i=0; $i<count($emailList); $i++)
{
$userExistInTeam = false;
foreach($teamMembers as $key => $member)
{
if($member['email'] == $emailList[$i])
{
$userExistInTeam = true;
}
}
if(!$userExistInTeam)
{
$user = insertInitialTeamMate($teamId, $emailList[$i], $teamLeader["companyId"]);
$emailTemplate = file_get_contents('./html/mail/index.html');
$emailValues = array(
'{#urlToLogo}' => 'http://dapalmes.com/teamEQapiRC/html/mail/img/teameq-logo.png',
'{#teamName}' => $teamLeader["teamName"],
'{#teamLeader}' => $teamLeader["name"] ." ". $teamLeader["surname"],
'{#invitationalToken}' => $user["token"],
'{#teamId}' => $teamId
);
$mail = new PHPMailer(true);
$body = strtr($emailTemplate, $emailValues);
$mail -> setFrom('no-reply#teameq.net', 'TeamEQ');
$mail -> AddAddress($emailList[$i]);
$mail -> Subject = "Has sido invitado a TeamEQ";
$mail -> MsgHTML($body);
// $result = $mail -> Send();
if(!$mail->Send())
{
echo "error al enviar!!";
}
else
{
echo "mensaje enviado";
}
}
}
the error was that the Send method is written lower case

You have an error in this line . Instead of
$mail -> AddAdress =$emailList[$i];
Use
$mail -> AddAddress($emailList[$i]);
Also this code will send the mail twice. so remove this line.
$result = $mail -> Send();

You shouldn't be calling Send() twice, check for $result instead:
$result = $mail -> Send();
if(!$result)
{
echo "send KO";
}
else
{
echo "send OK";
}
Also; try using $mail = new PHPMailer(true); instead; it should enable Exceptions and will tell you if & why sending failed

Related

Replace "Image" tag with "a" tag PHP DOMDocument

I have some HTML content like this
<p><b style="margin: 0px; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: Lato, Arial, Helvetica,
sans-serif; vertical-align: baseline; color: rgb(89, 89, 89);">'60 Degrees South Bar and Grill'</b><span style="color: rgb(89, 89, 89); font-family: Lato, Arial, Helvetica, sans-serif;">
is an imaginative and quirky space that allows diners to enjoy the sea breeze and spectacular views of the Indian Ocean from three terraces. The bar and Grill is ideally situated in </span>
<b style="margin: 0px; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: Lato, Arial, Helvetica,
sans-serif; vertical-align: baseline; color: rgb(89, 89, 89);">Stone Town</b><span style="color: rgb(89, 89, 89); font-family: Lato, Arial, Helvetica, sans-serif;"> on
the Shangani strip, perfect for a 'sundowner' while watching a breathtaking sunset. Choose from a glass of wine from their international selection or a </span>
<p><span style="color: rgb(89, 89, 89); font-family: Lato, Arial, Helvetica, sans-serif;">
<img alt="" src="https://green.com/files/images/Restaurants/60%20Degrees%20South-2.jpg" style="width: 550px; height: 491px;"></span></p>
<p><span style="color: rgb(89, 89, 89); font-family: Lato, Arial, Helvetica, sans-serif;">
<img alt="" src="https://green.com/files/images/Restaurants/60%20Degrees%20South-2.jpg" style="width: 550px; height: 491px;"></span>
</p>
I want to replace all img tag with a tag i am using PHP DOMDocument.
$dom = new DOMDocument();
$dom->loadHTML($content);
foreach ($dom->getElementsByTagName('img') as $img) {
$src = urldecode($img->getAttribute('src'));
if (!empty($src)) {
$link = $dom->createElement('a', "Image");
$link->setAttribute('target', '_blank');
$link->setAttribute('href', $src);
$img->parentNode->replaceChild($link, $img);
}
}
$dom->saveHTML();
This code will only replace only first img. How can i replace all img to a tag.
this is the output i am getting
<p><b style="margin: 0px; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: Lato, Arial, Helvetica,
sans-serif; vertical-align: baseline; color: rgb(89, 89, 89);">'60 Degrees South Bar and Grill'</b><span style="color: rgb(89, 89, 89); font-family: Lato, Arial, Helvetica, sans-serif;">
is an imaginative and quirky space that allows diners to enjoy the sea breeze and spectacular views of the Indian Ocean from three terraces. The bar and Grill is ideally situated in </span>
<b style="margin: 0px; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: Lato, Arial, Helvetica,
sans-serif; vertical-align: baseline; color: rgb(89, 89, 89);">Stone Town</b><span style="color: rgb(89, 89, 89); font-family: Lato, Arial, Helvetica, sans-serif;"> on
the Shangani strip, perfect for a 'sundowner' while watching a breathtaking sunset. Choose from a glass of wine from their international selection or a </span>
<p><span style="color: rgb(89, 89, 89); font-family: Lato, Arial, Helvetica, sans-serif;">
<a target="_blank" href="https://green.com/files/images/Restaurants/60%20Degrees%20South-1.jpg">Image</a></span></p>
<p><span style="color: rgb(89, 89, 89); font-family: Lato, Arial, Helvetica, sans-serif;">
<img alt="" src="https://green.com/files/images/Restaurants/60%20Degrees%20South-2.jpg" style="width: 550px; height: 491px;"></span>
</p>
This is a case of when you alter the content of the document your iterating over a (your list of tags in $dom->getElementsByTagName('img')) then it will cause problems. The way to get round this is to use XPath which creates a new list of nodes (the XPath query //img means find any <img> tag), then iterate over this...
$dom = new DOMDocument();
$dom->loadHTML($content);
$xp = new DOMXPath($dom);
foreach ($xp->query("//img") as $img) {
You can use preg_replace function
$pattern = '(<img)';
$replacement = '<a ';
$pattern2 = '(src=)';
$replacement2 = 'href= ';
$subject = Your text
$temp = preg_replace($pattern, $replacement, $subject, -1 );
echo preg_replace($pattern2, $replacement2, $temp, -1 );
The problem that PHP's DOMDocument class excels at:
=> Try this
<?php
$content = '<p><b style="margin: 0px; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: Lato, Arial, Helvetica,
sans-serif; vertical-align: baseline; color: rgb(89, 89, 89);">"60 Degrees South Bar and Grill"</b><span style="color: rgb(89, 89, 89); font-family: Lato, Arial, Helvetica, sans-serif;">
is an imaginative and quirky space that allows diners to enjoy the sea breeze and spectacular views of the Indian Ocean from three terraces. The bar and Grill is ideally situated in </span>
<b style="margin: 0px; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: Lato, Arial, Helvetica,
sans-serif; vertical-align: baseline; color: rgb(89, 89, 89);">Stone Town</b><span style="color: rgb(89, 89, 89); font-family: Lato, Arial, Helvetica, sans-serif;"> on
the Shangani strip, perfect for a "sundowner" while watching a breathtaking sunset. Choose from a glass of wine from their international selection or a </span>
<p><span style="color: rgb(89, 89, 89); font-family: Lato, Arial, Helvetica, sans-serif;">
<img alt="" src="https://green.com/files/images/Restaurants/60%20Degrees%20South-2.jpg" style="width: 550px; height: 491px;"></span></p>
<p><span style="color: rgb(89, 89, 89); font-family: Lato, Arial, Helvetica, sans-serif;">
<img alt="" src="https://green.com/files/images/Restaurants/60%20Degrees%20South-2.jpg" style="width: 550px; height: 491px;"></span>
</p>';
$dom = new DOMDocument();
$dom->loadHTML($content);
foreach ($dom->getElementsByTagName('img') as $img) {
$content = preg_replace("/<img[^>]+\>/i", '<a alt="" src="https://green.com/files/images/Restaurants/60%20Degrees%20South-2.jpg" style="width: 550px; height: 491px;">', $content);
echo $content;
}
$content = $dom->saveHTML();
?>
Demo :- https://paiza.io/projects/f7ege34jGw1LQsgvHZ01UA
OR
=> use this one for dynamic img path..
<?php
$content = '<p><b style="margin: 0px; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: Lato, Arial, Helvetica,
sans-serif; vertical-align: baseline; color: rgb(89, 89, 89);">"60 Degrees South Bar and Grill"</b><span style="color: rgb(89, 89, 89); font-family: Lato, Arial, Helvetica, sans-serif;">
is an imaginative and quirky space that allows diners to enjoy the sea breeze and spectacular views of the Indian Ocean from three terraces. The bar and Grill is ideally situated in </span>
<b style="margin: 0px; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: Lato, Arial, Helvetica,
sans-serif; vertical-align: baseline; color: rgb(89, 89, 89);">Stone Town</b><span style="color: rgb(89, 89, 89); font-family: Lato, Arial, Helvetica, sans-serif;"> on
the Shangani strip, perfect for a "sundowner" while watching a breathtaking sunset. Choose from a glass of wine from their international selection or a </span>
<p><span style="color: rgb(89, 89, 89); font-family: Lato, Arial, Helvetica, sans-serif;">
<img alt="" src="https://green.com/files/images/Restaurants/60%20Degrees%20South-2.jpg" style="width: 550px; height: 491px;"></span></p>
<p><span style="color: rgb(89, 89, 89); font-family: Lato, Arial, Helvetica, sans-serif;">
<img alt="" src="https://green.com/files/images/Restaurants/60%20Degrees%20South-2.jpg" style="width: 550px; height: 491px;"></span>
</p>';
$img = '(<img )';
$replace = '<a ';
echo preg_replace($img, $replace, $content, -1 );
?>

how do i insert php variable in html mail file

i have a php file to generate otp and sending html mail to user but i am unable to insert php variable it beacuse i am getting html mail content from other file please help me to do it
i want to insert below variable in html
$otpemail
$name
here is my php code
if (isset($_POST['resend'])) {
$uid = $_SESSION['usr_id'];
$otpemail=mt_rand(100000,999999);
$subject = "Email verification";
$email_from= "Go Alert <verification#goalert.in>";
$email_reply = "feedback#goalert.in";
$headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_reply."\r\n" .'X-Mailer: PHP/' . phpversion();
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$user =$db->getemail($uid);
if($user != NULL){
$email = $user['email'];
$name = $user['name'];
$status = "Not Verified";
$messageemail = file_get_contents('email.html');
$user=$db->resendemailotp($uid,$name,$email,$otpemail,$status);
#mail($email, $subject, $messageemail, $headers);
$errormsg1 = "Email Sent Please Check Spam if not recived";
}else {
$errormsg1 = "Error in Sending Email";
}
}
my html mail file codes are
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" style="background: #f0f0f0; min-height: 100%;" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="width=device-width" name="viewport" />
</head>
<body style="box-sizing: border-box; color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0; min-width: 100%; padding: 0; text-align: left; width: 100% !important;">
<table class="body" style="background: #f0f0f0; border-collapse: collapse; border-spacing: 0; color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; height: 100%; line-height: 19px; margin: 0; padding: 0; text-align: left; vertical-align: top; width: 100%;">
<tr style="padding: 0; text-align: left; vertical-align: top;">
<td align="center" class="center" style="border-collapse: collapse !important; color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; hyphens: auto; line-height: 19px; margin: 0; padding: 0; text-align: left; vertical-align: top; word-wrap: break-word;" valign="top">
<center data-parsed="" style="min-width: 580px; width: 100%;">
<table class="container text-center" style="background: #fefefe; border-collapse: collapse; border-spacing: 0; margin: 0 auto; padding: 0; text-align: center; vertical-align: top; width: 580px;">
<tbody>
<tr style="padding: 0; text-align: left; vertical-align: top;">
<td style="border-collapse: collapse !important; color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; hyphens: auto; line-height: 19px; margin: 0; padding: 0; text-align: left; vertical-align: top; word-wrap: break-word;">
<!-- This container adds the gap at the top of the email -->
<table class="row grey" style="background: #f0f0f0; border-collapse: collapse; border-spacing: 0; display: table; padding: 0; position: relative; text-align: left; vertical-align: top; width: 100%;">
<tbody>
<tr style="padding: 0; text-align: left; vertical-align: top;">
<th class="small-12 large-12 columns first last" style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0 auto; padding: 0; padding-bottom: 16px; padding-left: 16px; padding-right: 16px; text-align: left; width: 564px;">
<table style="border-collapse: collapse; border-spacing: 0; padding: 0; text-align: left; vertical-align: top; width: 100%;">
<tr style="padding: 0; text-align: left; vertical-align: top;">
<th style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0; padding: 0; text-align: left;">   </th>
<th class="expander" style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0; padding: 0 !important; text-align: left; visibility: hidden; width: 0;">
</th>
</tr>
</table>
</th>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<table class="container text-center" style="background: #fefefe; border-collapse: collapse; border-spacing: 0; margin: 0 auto; padding: 0; text-align: center; vertical-align: top; width: 580px;">
<tbody>
<tr style="padding: 0; text-align: left; vertical-align: top;">
<td style="border-collapse: collapse !important; color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; hyphens: auto; line-height: 19px; margin: 0; padding: 0; text-align: left; vertical-align: top; word-wrap: break-word;">
<!-- Main email content -->
<table class="row" style="border-collapse: collapse; border-spacing: 0; display: table; padding: 0; position: relative; text-align: left; vertical-align: top; width: 100%;">
<tbody>
<tr style="padding: 0; text-align: left; vertical-align: top;">
<!-- Logo -->
<th class="small-12 large-12 columns first last" style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0 auto; padding: 0; padding-bottom: 16px; padding-left: 16px; padding-right: 16px; text-align: left; width: 564px;">
<table style="border-collapse: collapse; border-spacing: 0; padding: 0; text-align: left; vertical-align: top; width: 100%;">
<tr style="padding: 0; text-align: left; vertical-align: top;">
<th style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0; padding: 0; text-align: left;">
<center data-parsed="" style="min-width: 532px; width: 100%;"><a align="center" class="text-center" href="http://www.goalert.in" style="color: #f7931d; font-family: Helvetica, Arial, sans-serif; font-weight: normal; line-height: 1.3; margin: 0; padding: 0; text-align: left; text-decoration: none;"> <img alt="Logo Image" class="swu-logo" src="https://www.goalert.in/test/assets/images/logo.png" style="border: none; clear: both; display: block; height: auto; max-width: 100%; outline: none; padding: 15px 0px 0px 0px; text-decoration: none; width: 170px;" /> </a></center>
</th>
<th class="expander" style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0; padding: 0 !important; text-align: left; visibility: hidden; width: 0;">
</th>
</tr>
</table>
</th>
</tr>
</tbody>
</table>
<table class="row masthead" style="background: #212121; border-collapse: collapse; border-spacing: 0; display: table; padding: 0; position: relative; text-align: left; vertical-align: top; width: 100%;">
<tbody>
<tr style="padding: 0; text-align: left; vertical-align: top;">
<!-- Masthead -->
<th class="small-12 large-12 columns first last" style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0 auto; padding: 0; padding-bottom: 16px; padding-left: 16px; padding-right: 16px; text-align: left; width: 564px;">
<table style="border-collapse: collapse; border-spacing: 0; padding: 0; text-align: left; vertical-align: top; width: 100%;">
<tr style="padding: 0; text-align: left; vertical-align: top;">
<th style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0; padding: 0; text-align: left;">
<h1 class="text-center" style="color: #f7931d; font-family: Helvetica, Arial, sans-serif; font-size: 34px; font-weight: normal; line-height: 1.3; margin: 0; margin-bottom: 10px; padding: 35px 0px 15px 0px; text-align: center; word-wrap: normal;">Download our Application</h1>
<center data-parsed="" style="min-width: 532px; width: 100%;"><a align="center" class="text-center" href="https://play.google.com/store/apps/details?id=in.com.goalert" style="color: #f7931d; font-family: Helvetica, Arial, sans-serif; font-weight: normal; line-height: 1.3; margin: 0; padding: 0; text-align: left; text-decoration: none;"> <img align="center" alt="Masthead Image" class="text-center" src="https://www.goalert.in/test/assets/images/play.png" style="border: none; clear: both; display: block; float: none; margin: 0 auto; max-width: 100%; outline: none; text-align: center; text-decoration: none; width: auto;" valign="bottom" /> </a></center>
</th>
<th class="expander" style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0; padding: 0 !important; text-align: left; visibility: hidden; width: 0;">
</th>
</tr>
</table>
</th>
</tr>
</tbody>
</table>
<table class="row" style="border-collapse: collapse; border-spacing: 0; display: table; padding: 0; position: relative; text-align: left; vertical-align: top; width: 100%;">
<tbody>
<tr style="padding: 0; text-align: left; vertical-align: top;">
<th class="small-12 large-12 columns first last" style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0 auto; padding: 0; padding-bottom: 16px; padding-left: 16px; padding-right: 16px; text-align: left; width: 564px;">
<table style="border-collapse: collapse; border-spacing: 0; padding: 0; text-align: left; vertical-align: top; width: 100%;">
<tr style="padding: 0; text-align: left; vertical-align: top;">
<th style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0; padding: 0; text-align: left;">   <!--This container adds the gap between masthead and digest content -->
</th>
<th class="expander" style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0; padding: 0 !important; text-align: left; visibility: hidden; width: 0;">
</th>
</tr>
</table>
</th>
</tr>
</tbody>
</table>
<table class="row" style="border-collapse: collapse; border-spacing: 0; display: table; padding: 0; position: relative; text-align: left; vertical-align: top; width: 100%;">
<tbody>
<tr style="padding: 0; text-align: left; vertical-align: top;">
<!-- Email copy -->
<th class="small-12 large-12 columns first last" style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0 auto; padding: 0; padding-bottom: 16px; padding-left: 16px; padding-right: 16px; text-align: left; width: 564px;">
<table style="border-collapse: collapse; border-spacing: 0; padding: 0; text-align: left; vertical-align: top; width: 100%;">
<tr style="padding: 0; text-align: left; vertical-align: top;">
<th style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0; padding: 0; text-align: left;">
<h5 style="color: inherit; font-family: Helvetica, Arial, sans-serif; font-size: 20px; font-weight: normal; line-height: 1.3; margin: 0; margin-bottom: 10px; padding: 0; text-align: left; word-wrap: normal;">Hi, {{name}}</h5>
<p style="color: #777777 !important; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0; margin-bottom: 10px; padding: 0; text-align: left;">Thankyou for suscribing with Go Alert.Now receive all application notifiaction into your mailbox.For faster information download our official mobile application from here</p>
<br />
<hr style="border-bottom: 1px solid #cacaca; border-left: 0; border-right: 0; border-top: 0; clear: both; height: 0; margin: 20px auto; max-width: 580px;" />
</th>
<th class="expander" style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0; padding: 0 !important; text-align: left; visibility: hidden; width: 0;">
</th>
</tr>
</table>
</th>
</tr>
</tbody>
</table>
<table class="row" style="border-collapse: collapse; border-spacing: 0; display: table; padding: 0; position: relative; text-align: left; vertical-align: top; width: 100%;">
<tbody>
<tr style="padding: 0; text-align: left; vertical-align: top;">
<th class="small-12 large-12 columns first last" style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0 auto; padding: 0; padding-bottom: 16px; padding-left: 16px; padding-right: 16px; text-align: left; width: 564px;">
<table style="border-collapse: collapse; border-spacing: 0; padding: 0; text-align: left; vertical-align: top; width: 100%;">
<tr style="padding: 0; text-align: left; vertical-align: top;">
<th style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0; padding: 0; text-align: left;">
<h5 class="text-center" style="color: inherit; font-family: Helvetica, Arial, sans-serif; font-size: 20px; font-weight: normal; line-height: 1.3; margin: 0; margin-bottom: 10px; padding: 0; text-align: center; word-wrap: normal;">Your OTP is</h5>
</th>
<th class="expander" style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0; padding: 0 !important; text-align: left; visibility: hidden; width: 0;">
</th>
</tr>
</table>
</th>
</tr>
</tbody>
</table>
<table class="row" style="border-collapse: collapse; border-spacing: 0; display: table; padding: 0; position: relative; text-align: left; vertical-align: top; width: 100%;">
<tbody>
<tr style="padding: 0; text-align: left; vertical-align: top;">
<!-- Coupon code box -->
<th class="small-12 large-4 columns first" style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0 auto; padding: 0; padding-bottom: 16px; padding-left: 16px; padding-right: 8px; text-align: left; width: 177.33333px;">
<table style="border-collapse: collapse; border-spacing: 0; padding: 0; text-align: left; vertical-align: top; width: 100%;">
<tr style="padding: 0; text-align: left; vertical-align: top;">
<th style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0; padding: 0; text-align: left;">
</th>
</tr>
</table>
</th>
<th class="grey small-12 large-12 columns" style="background: #f0f0f0; color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0 auto; padding: 0; padding-bottom: 16px; padding-left: 8px; padding-right: 8px; text-align: left; width: 564px;">
<table style="border-collapse: collapse; border-spacing: 0; padding: 0; text-align: left; vertical-align: top; width: 100%;">
<tr style="padding: 0; text-align: left; vertical-align: top;">
<th style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0; padding: 0; text-align: left;">
<br />
<h5 class="text-center" style="color: inherit; font-family: Helvetica, Arial, sans-serif; font-size: 20px; font-weight: normal; line-height: 1.3; margin: 0; margin-bottom: 10px; padding: 0; text-align: center; word-wrap: normal;" valign="middle">2ob3-32cc39-2pe3-291ab</h5>
</th>
<th class="expander" style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0; padding: 0 !important; text-align: left; visibility: hidden; width: 0;">
</th>
</tr>
</table>
</th>
<th class="small-12 large-4 columns last" style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0 auto; padding: 0; padding-bottom: 16px; padding-left: 8px; padding-right: 16px; text-align: left; width: 177.33333px;">
<table style="border-collapse: collapse; border-spacing: 0; padding: 0; text-align: left; vertical-align: top; width: 100%;">
<tr style="padding: 0; text-align: left; vertical-align: top;">
<th style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0; padding: 0; text-align: left;">
</th>
</tr>
</table>
</th>
</tr>
</tbody>
</table>
<table class="row" style="border-collapse: collapse; border-spacing: 0; display: table; padding: 0; position: relative; text-align: left; vertical-align: top; width: 100%;">
<tbody>
<tr style="padding: 0; text-align: left; vertical-align: top;">
<!-- Call to Action -->
<th class="small-12 large-12 columns first last" style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0 auto; padding: 0; padding-bottom: 16px; padding-left: 16px; padding-right: 16px; text-align: left; width: 564px;">
<table style="border-collapse: collapse; border-spacing: 0; padding: 0; text-align: left; vertical-align: top; width: 100%;">
<tr style="padding: 0; text-align: left; vertical-align: top;">
<th style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0; padding: 0; text-align: left;">
<center data-parsed="" style="min-width: 532px; width: 100%;">
<br align="center" class="text-center" />
<br align="center" class="text-center" />
<table class="button text-center" style="border-collapse: collapse; border-spacing: 0; margin: 0 0 16px 0; padding: 0; text-align: center; vertical-align: top; width: auto !important;">
<tr style="padding: 0; text-align: left; vertical-align: top;">
<td style="border-collapse: collapse !important; color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; hyphens: auto; line-height: 19px; margin: 0; padding: 0; text-align: left; vertical-align: top; word-wrap: break-word;">
<table style="border-collapse: collapse; border-spacing: 0; padding: 0; text-align: left; vertical-align: top; width: 100%;">
<tr style="padding: 0; text-align: left; vertical-align: top;">
<td style="background: #f7931d; border: 2px solid #f7931d; border-collapse: collapse !important; color: #fefefe; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; hyphens: auto; line-height: 19px; margin: 0; padding: 0; text-align: left; vertical-align: top; width: auto !important; word-wrap: break-word;">Download Our Application </td>
</tr>
</table>
</td>
</tr>
</table>
</center>
</th>
<th class="expander" style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0; padding: 0 !important; text-align: left; visibility: hidden; width: 0;">
</th>
</tr>
</table>
</th>
</tr>
</tbody>
</table>
<table class="row" style="border-collapse: collapse; border-spacing: 0; display: table; padding: 0; position: relative; text-align: left; vertical-align: top; width: 100%;">
<tbody>
<tr style="padding: 0; text-align: left; vertical-align: top;">
<!--This row adds the gap between masthead and digest content -->
<th class="small-12 large-12 columns first last" style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0 auto; padding: 0; padding-bottom: 16px; padding-left: 16px; padding-right: 16px; text-align: left; width: 564px;">
<table style="border-collapse: collapse; border-spacing: 0; padding: 0; text-align: left; vertical-align: top; width: 100%;">
<tr style="padding: 0; text-align: left; vertical-align: top;">
<th style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0; padding: 0; text-align: left;">   </th>
<th class="expander" style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0; padding: 0 !important; text-align: left; visibility: hidden; width: 0;">
</th>
</tr>
</table>
</th>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<!-- / End main email content -->
<table class="container text-center" style="background: #fefefe; border-collapse: collapse; border-spacing: 0; margin: 0 auto; padding: 0; text-align: center; vertical-align: top; width: 580px;">
<tbody>
<tr style="padding: 0; text-align: left; vertical-align: top;">
<td style="border-collapse: collapse !important; color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; hyphens: auto; line-height: 19px; margin: 0; padding: 0; text-align: left; vertical-align: top; word-wrap: break-word;">
<table class="row grey" style="background: #f0f0f0; border-collapse: collapse; border-spacing: 0; display: table; padding: 0; position: relative; text-align: left; vertical-align: top; width: 100%;">
<tbody>
<tr style="padding: 0; text-align: left; vertical-align: top;">
<th class="small-12 large-12 columns first last" style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0 auto; padding: 0; padding-bottom: 16px; padding-left: 16px; padding-right: 16px; text-align: left; width: 564px;">
<table style="border-collapse: collapse; border-spacing: 0; padding: 0; text-align: left; vertical-align: top; width: 100%;">
<tr style="padding: 0; text-align: left; vertical-align: top;">
<th style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0; padding: 0; text-align: left;">
<p class="text-center footercopy" style="color: #777777 !important; font-family: Helvetica, Arial, sans-serif; font-size: 12px; font-weight: normal; line-height: 19px; margin: 0; margin-bottom: 10px; padding: 20px 0px; text-align: center;">© Copyright 2016 Go Alert. All Rights Reserved.</p>
</th>
<th class="expander" style="color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: normal; line-height: 19px; margin: 0; padding: 0 !important; text-align: left; visibility: hidden; width: 0;">
</th>
</tr>
</table>
</th>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</center>
</td>
</tr>
</table>
</body>
</html>
Quick/dirty, use the output buffering system:
foo.html
<div><?php echo $var ?></div>
main script:
ob_start();
$var = 'hi mom!';
include('foo.html'); // executes any php code in the file
$html = ob_end_clean();
Alternatively, you could use a simple templating system:
foo.html:
<div>%VAR%</div>
main script:
$raw_html = file_get_contents('foo.html');
$var = 'hi mom!';
$complete_html = str_replace('%VAR%', $var, $raw_html);

Adding html template to swift email body

I'm new to swiftmailer and I could successfully send email using it. I need to add a html template to the email body. I'm not sure how to do that?
This is the code I used to
function sendMail($destinationEmail){
// Create the mail transport configuration
$transport = Swift_MailTransport::newInstance();
$html = "<html>
<head>
<title>Alerting System</title>
<style type=\"text/css\">
<!--
table {
font-family: Verdana, Arial, Helvetica, sans-serif;
border: thin solid;
}
th {
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #f0f0f0;
background-color: #ff0000;
font-size: 12px;
}
td {
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #000000;
font-size: 10px;
border: thin solid;
}
body {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
}
-->
</style>
<head>
<body>
<CENTER>
<TABLE width=\"50%\">
<TBODY>
<tr>
<th >test</th>
</tr>
</TBODY>
</TABLE>
<br>
Alerting and Reporting System
</CENTER></BODY></HTML>
";
// Create the message
$message = Swift_Message::newInstance();
$message->setTo(array(
$destinationEmail => "test",
$destinationEmail => "test mail"
));
$message->setSubject("This email is sent using Swift Mailer");
$message->setBody("You're our best client ever.");
$message->setFrom("test#testcom.com", "Alerts");
$message->attach($html, "text/html");
// Send the email
$mailer = Swift_Mailer::newInstance($transport);
$mailer->send($message);
}
How can I add this $html variable an email template? Any suggestion would be appreciated.
Use this
$html = "<html>
<head>
<title>Alerting System</title>
<style type=\"text/css\">
<!--
table {
font-family: Verdana, Arial, Helvetica, sans-serif;
border: thin solid;
}
th {
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #f0f0f0;
background-color: #ff0000;
font-size: 12px;
}
td {
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #000000;
font-size: 10px;
border: thin solid;
}
body {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
}
-->
</style>
<head>
<body>
<CENTER>
<TABLE width=\"50%\">
<TBODY>
<tr>
<th >test</th>
</tr>
</TBODY>
</TABLE>
<br>
Alerting and Reporting System
</CENTER></BODY></HTML>
";
$message->setBody($html,'text/html' // Mark the content-type as HTML);

how to integrate template inside email

i want to integrate template inside my email but the problem is that the path of the template that i am giving once arrived at my email box is displayed as a text.
so my script is :
$mail->From = 'user#gator4339.hostgator.com';
$mail->FromName = 'fekri';
$mail->addAddress('asa#gmail.com', 'fdgf'); // Add a recipient
$mail->addAddress('sa#gmail.com'); // Name is optional
$mail->addReplyTo('sa#gmail.com', 'ss');
$mail->addCC('cc#example.com');
$mail->addBCC('bcc#example.com');
$mail->isHTML(true); // Set email format to HTML
$message = realpath(dirname(__FILE__)) .'/../views/emailFoldre/sendemails.php';
$headers = 'from fekrin';
$mail->Body = realpath(dirname(__FILE__)) .'/../views/emailFoldre/sendemails.php';
// $mail->AltBody = 'This is a plain-text message body';
//mail('maqajma#gmail.com', $headers , $message);
if(!$mail->send()){
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
and as result i get home/publi_html..../../views/emailFoldre/sendemails.php
this is sendemails.php
<!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" xmlns="http://www.w3.org/1999/xhtml" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;">
<head>
<!-- If you delete this tag, the sky will fall on your head -->
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>ZURBemails</title>
</head>
<body bgcolor="#FFFFFF" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; width: 100% !important; height: 100%; margin: 0; padding: 0;">
<!-- HEADER -->
<table class="head-wrap" bgcolor="#999999" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; width: 100%; margin: 0; padding: 0;"><tr style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;"><td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;"></td>
<td class="header container" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; display: block !important; max-width: 600px !important; clear: both !important; margin: 0 auto; padding: 0;">
<div class="content" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; max-width: 600px; display: block; margin: 0 auto; padding: 15px;">
<table bgcolor="#999999" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; width: 100%; margin: 0; padding: 0;"><tr style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;"><td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;"><img src="http://placehold.it/200x50/" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; max-width: 100%; margin: 0; padding: 0;" /></td>
<td align="right" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;"><h6 class="collapse" style="font-family: 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; line-height: 1.1; color: #444; font-weight: 900; font-size: 14px; text-transform: uppercase; margin: 0; padding: 0;">Hero</h6></td>
</tr></table></div>
</td>
<td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;"></td>
</tr></table><!-- /HEADER --><!-- BODY --><table class="body-wrap" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; width: 100%; margin: 0; padding: 0;"><tr style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;"><td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;"></td>
<td class="container" bgcolor="#FFFFFF" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; display: block !important; max-width: 600px !important; clear: both !important; margin: 0 auto; padding: 0;">
<div class="content" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; max-width: 600px; display: block; margin: 0 auto; padding: 15px;">
<table style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; width: 100%; margin: 0; padding: 0;"><tr style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;"><td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;">
<h3 style="font-family: 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; line-height: 1.1; color: #000; font-weight: 500; font-size: 27px; margin: 0 0 15px; padding: 0;">Welcome, Elijah Baily</h3>
<p class="lead" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-weight: normal; font-size: 17px; line-height: 1.6; margin: 0 0 10px; padding: 0;">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et.</p>
<!-- A Real Hero (and a real human being) -->
<p style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-weight: normal; font-size: 14px; line-height: 1.6; margin: 0 0 10px; padding: 0;"><img src="http://placehold.it/600x300" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; max-width: 100%; margin: 0; padding: 0;" /></p><!-- /hero -->
<!-- Callout Panel -->
<p class="callout" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-weight: normal; font-size: 14px; line-height: 1.6; background-color: #ECF8FF; margin: 0 0 15px; padding: 15px;">
votre message a été envoyé à l'Annonceur avec avec Succès, Merci. Do it Now! »
</p><!-- /Callout Panel -->
<h3 style="font-family: 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; line-height: 1.1; color: #000; font-weight: 500; font-size: 27px; margin: 0 0 15px; padding: 0;">Title Ipsum <small style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 60%; color: #6f6f6f; line-height: 0; text-transform: none; margin: 0; padding: 0;">This is a note.</small></h3>
<p style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-weight: normal; font-size: 14px; line-height: 1.6; margin: 0 0 10px; padding: 0;">votre message a été envoyé à l'Annonceur avec avec Succès, Merci.</p>
<a class="btn" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; color: #FFF; text-decoration: none; font-weight: bold; text-align: center; cursor: pointer; display: block !important; background-image: none !important; background-color: #666; margin: 0 0 10px; padding: 10px 16px;">Click Me!</a>
<br style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;" /><br style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;" /><!-- social & contact --><table class="social" width="100%" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; width: 100%; background-color: #ebebeb; margin: 0; padding: 0;" bgcolor="#ebebeb"><tr style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;"><td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;">
<!--- column 1 -->
<table align="left" class="column" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; width: 280px; float: left; min-width: 279px; margin: 0; padding: 0;"><tr style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;"><td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 15px;">
<h5 class="" style="font-family: 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; line-height: 1.1; color: #000; font-weight: 900; font-size: 17px; margin: 0 0 15px; padding: 0;">Connect with Us:</h5>
<p class="" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-weight: normal; font-size: 14px; line-height: 1.6; margin: 0 0 10px; padding: 0;">Facebook Twitter Google+</p>
</td>
</tr></table><!-- /column 1 --><!--- column 2 --><table align="left" class="column" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; width: 280px; float: left; min-width: 279px; margin: 0; padding: 0;"><tr style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;"><td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 15px;">
<h5 class="" style="font-family: 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; line-height: 1.1; color: #000; font-weight: 900; font-size: 17px; margin: 0 0 15px; padding: 0;">Contact Info:</h5>
<p style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-weight: normal; font-size: 14px; line-height: 1.6; margin: 0 0 10px; padding: 0;">Phone: <strong style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;">408.341.0600</strong><br style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;" />
Email: <strong style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;">hseldon#trantor.com</strong></p>
</td>
</tr></table><!-- /column 2 --><span class="clear" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; display: block; clear: both; margin: 0; padding: 0;"></span>
</td>
</tr></table><!-- /social & contact --></td>
</tr></table></div>
</td>
<td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;"></td>
</tr></table><!-- /BODY --><!-- FOOTER --><table class="footer-wrap" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; width: 100%; clear: both !important; margin: 0; padding: 0;"><tr style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;"><td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;"></td>
<td class="container" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; display: block !important; max-width: 600px !important; clear: both !important; margin: 0 auto; padding: 0;">
<!-- content -->
<div class="content" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; max-width: 600px; display: block; margin: 0 auto; padding: 15px;">
<table style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; width: 100%; margin: 0; padding: 0;"><tr style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;"><td align="center" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;">
<p style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-weight: normal; font-size: 14px; line-height: 1.6; margin: 0 0 10px; padding: 0;">
Terms |
Privacy |
<unsubscribe style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;">Unsubscribe</unsubscribe>
</p>
</td>
</tr></table></div><!-- /content -->
</td>
<td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;"></td>
</tr></table><!-- /FOOTER --></body>
</html>
The $mail->Body in this code is set to the file's name, and not the file's content. To fix it, and assuming the file name is correct, the following line:
$mail->Body = realpath(dirname(__FILE__)) .'/../views/emailFoldre/sendemails.php';
Should be simply changed to:
$mail->Body = file_get_contents(realpath(dirname(__FILE__)) .'/../views/emailFoldre/sendemails.php');
Notes:
$message isn't used anywhere - it's better to remove it to avoid confusion
Indentation really needs to be fixed

Syntax Error: Unexpected "&lt" on Line 1

Not sure why it's doing this, but I'm getting the following syntax error: "Unexpected "&lt" on Line1".
I can't seem to find out what is the problem, I've already tried troubleshooting the problem earlier before posting this.
Here's my code:
<?php
include($_SERVER["DOCUMENT_ROOT"].'/admin/classes/classes.php'); // Include local class lib
$sess = new SessionData(); // Creates session object
//$sess->CheckValidFBSession();
if($sess->CheckValidSession()){
header('Location: home.php');
}
$log= new log($_SERVER["PHP_SELF"], $_GET, $_POST, $_SERVER['HTTP_REFERER'] );
$stats=new Statistics();
$totalusers=$stats->totalscope();
?>
<html xmlns:fb="//www.facebook.com/2008/fbml">
<style>
.title {
color:#000000;
font-Family: Tahoma, Arial, Helvetica, sans-serif;
font-size: 18px;
font-weight: bold;
text-decoration:none;
}
.larger {
color:#000000;
font-Family: Tahoma, Arial, Helvetica, sans-serif;
font-size: 13px;
font-weight: none;
text-decoration:none;
}
.larger-a {
//color:#D19160;
color:#538ADC;
font-Family: Tahoma, Arial, Helvetica, sans-serif;
font-size: 13px;
font-weight: none;
text-decoration:none;
}
.larger-a:hover {
//color:#FF0000;
color:#77C9F3;
font-Family: Tahoma, Arial, Helvetica, sans-serif;
font-size: 13px;
font-weight: none;
text-decoration:underline;
}
select {
font-family: Tahoma;
font-size: 11px;
}
.white {
color:#FFFFFF;
font-Family: Tahoma, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: none;
text-decoration:none;
}
.blue {
color:#3B5998;
font-Family: Tahoma, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: none;
text-decoration:none;
}
.red {
color:#FF0000;
font-Family: Tahoma, Arial, Helvetica, sans-serif;
font-size: 11px;
font-weight: none;
text-decoration:none;
}
.menu {
color:#FFFFFF;
font-Family: Tahoma, Arial, Helvetica, sans-serif;
font-size: 11px;
font-weight: none;
text-decoration:none;
}
.menu:hover {
color:#77C9F3;
font-Family: Tahoma, Arial, Helvetica, sans-serif;
font-size: 11px;
font-weight: none;
text-decoration:none;
}
.alternate {
color:#3B5998;
font-Family: Tahoma, Arial, Helvetica, sans-serif;
font-size: 11px;
font-weight: none;
text-decoration:none;
}
.alternate:hover {
color:#000000;
font-Family: Tahoma, Arial, Helvetica, sans-serif;
font-size: 11px;
font-weight: none;
text-decoration:underline;
}
a {
//color:#D19160;
color:#538ADC;
font-Family: Tahoma, Arial, Helvetica, sans-serif;
font-size: 11px;
font-weight: none;
text-decoration:none;
}
a:hover {
//color:#FF0000;
color:#77C9F3;
font-Family: Tahoma, Arial, Helvetica, sans-serif;
font-size: 11px;
font-weight: none;
text-decoration:underline;
}
.bordertable {
border-width: 1px;
border-color: #3B5998;
border-style: solid;
}
.dashedtable {
border-width: 1px;
border-color: #3B5998;
border-style: dashed;
}
.bottomborder {
border-style:solid;
border-color: #3B5998;
border-top-width:0px;
border-bottom-width:1px;
border-right-width:0px;
border-left-width:0px;
}
.one-column {
color:#000000;
font-Family: Tahoma, Arial, Helvetica, sans-serif;
font-size: 11px;
font-weight: none;
text-decoration:none;
border-style:solid;
border-color: #3B5998;
border-top-width:1px;
border-bottom-width:0px;
border-right-width:1px;
border-left-width:1px;
}
.text {
font-Family: Serif;
font-size: 11px;
font-weight: none;
text-decoration:none;
}
.td0 {
color:#000000;
background-color:#D9DFEA;
border: 0;
font-Family: Tahoma, Arial, Helvetica, sans-serif;
font-size: 11px;
font-weight: none;
text-decoration:none;
}
.td1 {
color:#000000;
background-color:#86A1CE;
border: 0;
font-Family: Tahoma, Arial, Helvetica, sans-serif;
font-size: 11px;
font-weight: none;
text-decoration:none;
}
.schedule_table {
border-right-width: 0px;
border-bottom-width: 0px;
border-left-width: 1px;
border-top-width: 1px;
border-style: solid;
border-color: #000000;
}
.top-border {
border-right-width: 0px;
border-bottom-width: 0px;
border-left-width: 0px;
border-top-width: 1px;
border-style: solid;
border-color: #3B5998;
}
.schedule {
color:#000000;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 0px;
border-top-width: 0px;
border-style: solid;
border-color:#000000;
font-Family: Tahoma, Arial, Helvetica, sans-serif;
font-size: 11px;
font-weight: none;
text-decoration:none;
}
.border-td {
color:#000000;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-width: 1px;
border-style: solid;
border-color:#3B5998;
font-Family: Tahoma, Arial, Helvetica, sans-serif;
font-size: 11px;
font-weight: none;
text-decoration:none;
}
td {
color:#000000;
border: 0;
font-Family: Tahoma, Arial, Helvetica, sans-serif;
font-size: 11px;
font-weight: none;
text-decoration:none;
}
.inputtext {
border:double;
border-width:1;
border-color:#555555;
background-color:#D9DFEA;
font-size:11px;
color: #000000;
font-Family: Tahoma, Arial, Helvetica, sans-serif;
}
.inputsubmit {
border-style:solid;
border-top-width:1px;
border-bottom-width:2px;
border-right-width:2px;
border-left-width:1px;
border-top-color:#D9DFEA;
border-bottom-color:#3B5998;
border-right-color:#3B5998;
border-left-color:#D9DFEA;
background-color:#538ADC;
font-family:Tahoma, arial;
font-size:11px;
color:#FFFFFF;
font-weight:none;
}
a img{
border:none !important;
}
#container{
margin:0 auto;
width:500px;
padding:40px;
text-align:left;
background-color:#fff;
}
#lightbox h2{
margin:0 0 1em 0;
}
#lightbox h3{
color:#FF713F;
}
#lightbox.done p{
color:#333;
}
#form{
text-align:left;
margin:25px;
}
#form ul{
list-style:none;
}
#form li{
margin:0 0 1em 0;
}
#form textarea{
width:100%;
height:150px;
}
#definition{
margin:25px;
}
.highlight{
background-color:#FEFFAF;
}
#lightbox{
display:none;
position: absolute;
top:50%;
left:50%;
z-index:9999;
width:400px;
height:200px;
padding:10px;
margin:-220px 0 0 -250px;
border:1px solid #fff;
background:#FDFCE9;
text-align:left;
}
#lightbox[id]{
position:fixed;
}
#overlay{
display:none;
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
z-index:5000;
background-color:#000;
-moz-opacity: 0.8;
opacity:.80;
filter: alpha(opacity=80);
}
#overlay[id]{
position:fixed;
}
#lightbox.done #lbLoadMessage{
display:none;
}
#lightbox.done #lbContent{
display:block;
}
#lightbox.loading #lbContent{
display:none;
}
#lightbox.loading #lbLoadMessage{
display:block;
}
#lightbox.done img{
width:100%;
height:100%;
}
<!--
#8EA7C5 - blue
#D9DFEA - grey
59 89 152 (#3B5998)
217 223 234 (#D9DFEA)
83 138 220 - link normal (#538ADC)
119 201 243 - link down (#77C9F3)
-->
</style>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '<?php echo $sess->fbappid; ?>',
session : <?php echo json_encode($sess->fbsession); ?>, // don't refetch the session when PHP already has it
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
};
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
<title>Kuarrel | Welcome to Kuarrel!</title>
<meta name="description" content="Kuarrel is an online directory that connects people from throughout the world." />
<meta name="keywords" content="kuarrel, chaibear, chai, sa-mp, sa:mp, 2014" />
<meta name="Generator" content="JB engine designed" />
<meta name="robots" content="index, follow" />
<meta name="OriginalPublicationDate" content="2014/03/12/01:37:22">
<meta name="Headline" content="Kuarrel | Welcome to Kuarrel!">
<meta name="IFS_URL" content="/index.php">
<meta name="contentFlavor" content="PAGE">
<meta name="CPS_SITE_NAME" content="Kuarrel | Welcome to Kuarrel">
<meta name="CPS_SECTION_PATH" content="Index">
<meta name="CPS_ASSET_TYPE" content="STY">
<meta name="CPS_PLATFORM" content="HighWeb">
<meta name="CPS_AUDIENCE" content="US">
<meta property="og:title" content="Kuarrel is an online directory that connects people from throughout the world.">
<meta property="og:type" content="website">
<meta property="og:description" content="Kuarrel is an online directory that connects people from throughout the world.">
<meta property="og:image" content="http://www.kuarrel.tk/images/logo-right.jpg">
<meta property="og:url" content="http://www.kuarrel.tk/index.php">
<meta property="og:site_name" content="Kuarrel">
<!-- sO3vWw3hwrnxdrwPGTKy2ZOW6yU -->
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.Canvas.setAutoResize();
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
<script src="//connect.facebook.net/en_US/all.js#appId=194568130593245&xfbml=1"></script>
<center>
<table class="bordertable" cellspacing=0 cellpadding=0 border=0 width=700>
<tr><td>
<table class="bottomborder" cellspacing=0 cellpadding=0 border=0 width=100%>
<tr><td width=350 bgcolor=#3B5998>
<img src='images/logo-left.jpg'></td>
<td><table cellspacing=0 cellpadding=0 border=0 width=100%><tr><td>
<table cellspacing=0 cellpadding=0 border=0 width=100%>
<tr><td><a href='register.php'><img alt='Register' src='images/logo-right.jpg' border=0></a></td>
<td width=100% bgcolor=#3B5998> </td></tr></table></td></tr>
<tr><td><table cellspacing=0 cellpadding=4 border=0 width=100%><tr height=21>
<!--<td bgcolor=#3B5998 width=10> </td>-->
<?PHP
if(!$sess->CheckValidSession()){
include('modules/default/topnav.php');
}else{
include('modules/loggedin/topnav.php');
}
?> <td bgcolor=#3B5998 width=100%> </td>
</tr></table></td>
</tr></table>
</td></tr></table>
</td></tr>
<tr><td><table cellspacing=0 cellpadding=2 border=0 width=100%>
<tr><td valign=top>
<table cellspacing=0 cellpadding=0 border=0 width=105>
<tr><td>
<?PHP
if(!$sess->CheckValidSession()){
include('modules/default/leftnav.php');
}else{
include('modules/loggedin/leftnav.php');
}
?>
</td></tr>
</table>
</td><td width=595 valign=top>
<table class="bordertable" cellspacing=0 cellpadding=0 border=1 width=100%><tr><td>
<table cellspacing=0 cellpadding=2 border=0 width=100%>
<tr><td class='white' bgcolor=#3B5998>Welcome to Kaurrel!</td></tr></table><center><p class='title'>[ Welcome to Kaurell ]<br>
<table cellspacing=0 cellpadding=0 border=0 width=95%>
<tr><td class='larger'><?=(!empty($_GET['error']));?>"<span style='color:red;font-size:16px;'>Facebook login has been disabled for today, please try again tomorrow.</span><br><br>Kaurell is an online directory that connects people from Facebook through social networks at colleges.
<p>We have opened up Kaurell for popular consumption at <b>all colleges and universities</b>. If you are not part of a college or university, you will be added to the default Kaurell network.
<p>Your account is limited to your own college or university.
<p>You can use Kaurell to:
<br> <b>•</b> Search for people at your school
<br> <b>•</b> Find out who are in your classes
<br> <b>•</b> Look up your friends' friends
<br> <b>•</b> See a visualization of your social network
<p>To get started, click below to register with your Facebook account.<!--<br><font size="+1">Join the <?=$totalusers?> people at Kaurell today.</font>-->
<center>
<?php if(strlen($_SESSION['notpartofacollege'])>2){
echo "<b>".$_SESSION['notpartofacollege']."</b>";
}
?>
<div id="fb-root"></div>
<center><input class='inputsubmit' type="button" value='Register' onclick='javascript:document.location="register.php";'> <input class='inputsubmit' type="button" value=' Login ' onclick='javascript:document.location="login.php";'>
<br> </td></tr></table> </td></tr></table>
</td></tr></table>
<center>
<?PHP include('modules/default/bottomnav.php'); ?>
</center><br>
</td></tr></table>
Thanks to anyone who can figure out what's going on here!
try to correct
<?=(!empty($_GET['error']))?
to
<?=(!empty($_GET['error']));?>
also </span><br><br>":""?> to </span><br><br>

Categories