karthik80c
asked on
Php Email function not working with Template
Hi Experts,
We are trying to load the email template on Mail Function . But while using the template the email function not working . Whereas Ordinary string the mail function working . Any thing Behind the scene is blocking the mail
Thanks in Advance Experts
We are trying to load the email template on Mail Function . But while using the template the email function not working . Whereas Ordinary string the mail function working . Any thing Behind the scene is blocking the mail
$to = $email;
$message = file_get_contents('email.html');
// Replace the % with the actual information
//$message ='test message';
$to =$email ;
$from = 'hello@test.com';
$headers = "From: " . strip_tags($from) . "\r\n";
$headers .= "Reply-To: ". strip_tags($from) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$check = mail($to,"GET YOUR QUOTE", , $headers);
if($check){
echo "Message sent successfully !";
}
Thanks in Advance Experts
ASKER
Hi Dave,
When we set the to mail address to the variable it's not working. But when put dummy string on message variable it works
When we set the to mail address to the variable it's not working. But when put dummy string on message variable it works
Please add this statement before line 1 (after the start-PHP tag):
error_reporting(E_ALL);
Please add this statement on line 15:
var_dump($to, $message);
Please change line 16 to this statement:
$check = mail($to, "GET YOUR QUOTE", $message, $headers);
Then show us the output from var_dump() and the email message that was received, thanks.
error_reporting(E_ALL);
Please add this statement on line 15:
var_dump($to, $message);
Please change line 16 to this statement:
$check = mail($to, "GET YOUR QUOTE", $message, $headers);
Then show us the output from var_dump() and the email message that was received, thanks.
ASKER
Hi Ray,
When we go for var dump we got the Html Email Template is displaying and I suspect my email template currently have some broken image and when we tried with another email template [No Broken Image] then we got the email template in mail.
When we go for var dump we got the Html Email Template is displaying and I suspect my email template currently have some broken image and when we tried with another email template [No Broken Image] then we got the email template in mail.
show us the output from var_dump() and the email message that was received, please
ASKER
Hi Ray ,
We got the Html source code on var_dump($message); Url Link
We got the Html source code on var_dump($message); Url Link
am hereCongratsstring(7781) "
<!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>[SUBJECT]</title>
<style type="text/css">
body {
padding-top: 0 !important;
padding-bottom: 0 !important;
padding-top: 0 !important;
padding-bottom: 0 !important;
margin:0 !important;
width: 100% !important;
-webkit-text-size-adjust: 100% !important;
-ms-text-size-adjust: 100% !important;
-webkit-font-smoothing: antialiased !important;
}
.tableContent img {
border: 0 !important;
display: block !important;
outline: none !important;
}
a{
color:#382F2E;
}
p, h1,ul,ol,li,div{
margin:0;
padding:0;
}
td,table{
vertical-align: top;
}
td.middle{
vertical-align: middle;
}
a.link1{
color:#D0021B;
text-decoration:none;
}
.link2{
font-size:13px;
color:#999999;
text-decoration:none;
line-height:19px;
}
@media only screen and (max-width:480px)
{
table[class="MainContainer"], td[class="cell"]
{
width: 100% !important;
height:auto !important;
}
td[class="specbundle"]
{
width: 100% !important;
float:left !important;
font-size:13px !important;
line-height:17px !important;
display:block !important;
padding-bottom:15px !important;
}
td[class="specbundle2"]
{
width:90% !important;
float:left !important;
font-size:14px !important;
line-height:18px !important;
display:block !important;
padding-bottom:10px !important;
padding-left:5% !important;
padding-right:5% !important;
}
td[class="spechide"]
{
display:none !important;
}
img[class="banner"]
{
width: 100% !important;
height: auto !important;
}
td[class="left_pad"]
{
padding-left:15px !important;
padding-right:15px !important;
}
}
@media only screen and (max-width:540px)
{
table[class="MainContainer"], td[class="cell"]
{
width: 100% !important;
height:auto !important;
}
td[class="specbundle"]
{
width: 100% !important;
float:left !important;
font-size:13px !important;
line-height:17px !important;
display:block !important;
padding-bottom:15px !important;
}
td[class="specbundle2"]
{
width:90% !important;
float:left !important;
font-size:14px !important;
line-height:18px !important;
display:block !important;
padding-bottom:10px !important;
padding-left:5% !important;
padding-right:5% !important;
}
td[class="spechide"]
{
display:none !important;
}
img[class="banner"]
{
width: 100% !important;
height: auto !important;
}
td[class="left_pad"]
{
padding-left:15px !important;
padding-right:15px !important;
}
}
</style>
</head>
<body paddingwidth="0" paddingheight="0" bgcolor="#d1d3d4" style="padding-top: 0; padding-bottom: 0; padding-top: 0; padding-bottom: 0; background-repeat: repeat; width: 100% !important; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; -webkit-font-smoothing: antialiased;" offset="0" toppadding="0" leftpadding="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tableContent" align="center" bgcolor="#4d4545" style='font-family:helvetica, sans-serif;'>
<!-- ================ header=============== -->
<tbody>
<tr>
<td><table width="600" border="0" cellspacing="0" cellpadding="0" align="center" class="MainContainer">
<!-- END HEAD -->
<!-- BODY -->
<tbody>
<tr>
<td class='movableContentContainer'>
<div class="movableContent" style="border: 0px; padding-top: 0px; position: relative;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td height='22' bgcolor='#ffffff'></td>
</tr>
<tr>
<td bgcolor='#ffffff'><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" width="20" class="spechide"> </td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" width="340" class="specbundle2"><div class="contentEditableContainer contentImageEditable">
<div class="contentEditable" >
<img src="http://kaybs.in/test/cron/images/logo.png" data-max-width="340" alt='[CLIENTS.COMPANY_NAME]'>
</div>
</div></td>
<td valign="top" class="specbundle2" align='right'><div class="contentEditableContainer contentTextEditable">
<div style='font-size:14px;' class="contentEditable" >
<!-- <p ><a target='_blank' href="#" class='link1'>About us</a> / <a target='_blank' href="#" class='link1'>Contact</a> / <a target='_blank' href="#" class='link1'>Menu</a></p> -->
</div>
</div></td>
</tr>
</tbody>
</table></td>
<td valign="top" width="20" class="spechide"> </td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
<div class="movableContent" style="border: 0px; padding-top: 0px; position: relative;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td height='22' bgcolor='#ffffff'></td></tr>
<tr>
<td bgcolor='#B57801'>
<div class="contentEditableContainer contentImageEditable">
<div class="contentEditable" >
<img class="banner" src="http://kaybs.in/test/cron/images/gold-price111212111.jpg" data-default="placeholder" data-max-width="600" width='600' height='400' alt='Gold Rate!' border="0">
</div>
</div>
</td>
</tr>
</table>
</div>
<div class="movableContent" style="border: 0px; padding-top: 0px; position: relative;">
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor='#D0021B'>
<tr><td height='55' colspan='3'></td></tr>
<tr>
<td width='125'></td>
<td>
<table width="350" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<div class="contentEditableContainer contentTextEditable">
<div style='font-family:Georgia;font-size:36px;color:#ffffff;text-align:center;' class="contentEditable" >
<p >Gold Rate [FirstName, buddy]!</p>
</div>
</div>
</td>
</tr>
<tr><td height='25'></td></tr>
<tr>
<td>
<div class="contentEditableContainer contentTextEditable">
<div style='font-family:Georgia;font-size:15px;color:#ffffff;line-height:17px;text-align:center;' class="contentEditable" >
<p>
[Details]
</p>
</div>
</div>
</td>
</tr>
</table>
</td>
<td width='125'></td>
</tr>
<tr><td height='55' colspan='3'></td></tr>
</table>
</div>
</body>
</html>
"
<!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>[SUBJECT]</title>
<style type="text/css">
body {
padding-top: 0 !important;
padding-bottom: 0 !important;
padding-top: 0 !important;
padding-bottom: 0 !important;
margin:0 !important;
width: 100% !important;
-webkit-text-size-adjust: 100% !important;
-ms-text-size-adjust: 100% !important;
-webkit-font-smoothing: antialiased !important;
}
.tableContent img {
border: 0 !important;
display: block !important;
outline: none !important;
}
a{
color:#382F2E;
}
p, h1,ul,ol,li,div{
margin:0;
padding:0;
}
td,table{
vertical-align: top;
}
td.middle{
vertical-align: middle;
}
a.link1{
color:#D0021B;
text-decoration:none;
}
.link2{
font-size:13px;
color:#999999;
text-decoration:none;
line-height:19px;
}
@media only screen and (max-width:480px)
{
table[class="MainContainer"], td[class="cell"]
{
width: 100% !important;
height:auto !important;
}
td[class="specbundle"]
{
width: 100% !important;
float:left !important;
font-size:13px !important;
line-height:17px !important;
display:block !important;
padding-bottom:15px !important;
}
td[class="specbundle2"]
{
width:90% !important;
float:left !important;
font-size:14px !important;
line-height:18px !important;
display:block !important;
padding-bottom:10px !important;
padding-left:5% !important;
padding-right:5% !important;
}
td[class="spechide"]
{
display:none !important;
}
img[class="banner"]
{
width: 100% !important;
height: auto !important;
}
td[class="left_pad"]
{
padding-left:15px !important;
padding-right:15px !important;
}
}
@media only screen and (max-width:540px)
{
table[class="MainContainer"], td[class="cell"]
{
width: 100% !important;
height:auto !important;
}
td[class="specbundle"]
{
width: 100% !important;
float:left !important;
font-size:13px !important;
line-height:17px !important;
display:block !important;
padding-bottom:15px !important;
}
td[class="specbundle2"]
{
width:90% !important;
float:left !important;
font-size:14px !important;
line-height:18px !important;
display:block !important;
padding-bottom:10px !important;
padding-left:5% !important;
padding-right:5% !important;
}
td[class="spechide"]
{
display:none !important;
}
img[class="banner"]
{
width: 100% !important;
height: auto !important;
}
td[class="left_pad"]
{
padding-left:15px !important;
padding-right:15px !important;
}
}
</style>
</head>
<body paddingwidth="0" paddingheight="0" bgcolor="#d1d3d4" style="padding-top: 0; padding-bottom: 0; padding-top: 0; padding-bottom: 0; background-repeat: repeat; width: 100% !important; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; -webkit-font-smoothing: antialiased;" offset="0" toppadding="0" leftpadding="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tableContent" align="center" bgcolor="#4d4545" style='font-family:helvetica, sans-serif;'>
<!-- ================ header=============== -->
<tbody>
<tr>
<td><table width="600" border="0" cellspacing="0" cellpadding="0" align="center" class="MainContainer">
<!-- END HEAD -->
<!-- BODY -->
<tbody>
<tr>
<td class='movableContentContainer'>
<div class="movableContent" style="border: 0px; padding-top: 0px; position: relative;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td height='22' bgcolor='#ffffff'></td>
</tr>
<tr>
<td bgcolor='#ffffff'><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" width="20" class="spechide"> </td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" width="340" class="specbundle2"><div class="contentEditableContainer contentImageEditable">
<div class="contentEditable" >
<img src="http://kaybs.in/test/cron/images/logo.png" data-max-width="340" alt='[CLIENTS.COMPANY_NAME]'>
</div>
</div></td>
<td valign="top" class="specbundle2" align='right'><div class="contentEditableContainer contentTextEditable">
<div style='font-size:14px;' class="contentEditable" >
<!-- <p ><a target='_blank' href="#" class='link1'>About us</a> / <a target='_blank' href="#" class='link1'>Contact</a> / <a target='_blank' href="#" class='link1'>Menu</a></p> -->
</div>
</div></td>
</tr>
</tbody>
</table></td>
<td valign="top" width="20" class="spechide"> </td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
<div class="movableContent" style="border: 0px; padding-top: 0px; position: relative;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td height='22' bgcolor='#ffffff'></td></tr>
<tr>
<td bgcolor='#B57801'>
<div class="contentEditableContainer contentImageEditable">
<div class="contentEditable" >
<img class="banner" src="http://kaybs.in/test/cron/images/gold-price111212111.jpg" data-default="placeholder" data-max-width="600" width='600' height='400' alt='Gold Rate!' border="0">
</div>
</div>
</td>
</tr>
</table>
</div>
<div class="movableContent" style="border: 0px; padding-top: 0px; position: relative;">
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor='#D0021B'>
<tr><td height='55' colspan='3'></td></tr>
<tr>
<td width='125'></td>
<td>
<table width="350" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<div class="contentEditableContainer contentTextEditable">
<div style='font-family:Georgia;font-size:36px;color:#ffffff;text-align:center;' class="contentEditable" >
<p >Gold Rate [FirstName, buddy]!</p>
</div>
</div>
</td>
</tr>
<tr><td height='25'></td></tr>
<tr>
<td>
<div class="contentEditableContainer contentTextEditable">
<div style='font-family:Georgia;font-size:15px;color:#ffffff;line-height:17px;text-align:center;' class="contentEditable" >
<p>
[Details]
</p>
</div>
</div>
</td>
</tr>
</table>
</td>
<td width='125'></td>
</tr>
<tr><td height='55' colspan='3'></td></tr>
</table>
</div>
</body>
</html>
Message sent successfully !happy.harishankar@gmail.com
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, Ray. Well worth Suggestion
I think I got the Solution. I tried with some other email template and its works and I noticed that my email template has some broken images Don't know exactly this will cause the email to not send
I think I got the Solution. I tried with some other email template and its works and I noticed that my email template has some broken images Don't know exactly this will cause the email to not send
Open in new window
Also, you do not actually have a recipient defined in the code above. I suspect there is a lot missing from your code.http://php.net/manual/en/function.mail.php