Page 1 of 1

i need help to send email containing html code by php

Posted: Tue Nov 18, 2008 8:03 am
by asifkamalzahid
i am sending this email to my inbox but it not showing me the data in my design formate.



function sendemails($title,$fname,$sname,$email){
$orderNo_ses= $_SESSION['orderNo'];
//$theCustName ="";
//$orderno = "";
$emailTo = $email;
//$emailTo = "nick@lovelljohns.com";

//$emailBody ="";

$strCustomerName = $title . $fname . " " .$sname;
$strCurrentOrderNo = $orderNo_ses;

$strEmailbody = "<html><head><meta http-equiv='Content-Type'content='text/html; charset=iso-8859-1'>";
$strEmailbody .= "<title>GreenAsap Order Confirmation</title>";
$strEmailbody .= "<style type='text/css'>";
$strEmailbody .= "<!--";
$strEmailbody .= ".maintext {font-family: Helvetica, Arial, sans-serif;size: 12pt;color:#000000}";
$strEmailbody .= ".green {font-family: Helvetica, Arial, sans-serif;size: 12pt;color:#85BC3F}";
$strEmailbody .= ".purple {font-family: Helvetica, Arial, sans-serif;size: 12pt;color:#00365A}";
$strEmailbody .= ".grey {font-family: Helvetica, Arial, sans-serif;size: 12pt;color:#808080}";
$strEmailbody .= "-->";
$strEmailbody .= "</style></head><body>";
$strEmailbody .= "<img src='http://www.mapsinternational.co.uk/nic_temp/header.bmp'>";
$strEmailbody .= "<p class='maintext'>Dear " . $strCustomerName . ",</p>";
$strEmailbody .= "<p class='maintext'>Report order: " . $strCurrentOrderNo . "</p>";
$strEmailbody .= "<p class='maintext'>Thank you for ordering a <span class='green'><strong>Green</strong></span><span class='purple'><strong>Light</strong></span><span class='grey'><strong> Report</strong><sup>&reg;</sup></span>.";
$strEmailbody .= "Your report order will be shortly processed by one of our skilled Environmental Surveyors.";
$strEmailbody .= "<p class='maintext'>Remember to regularly check <strong><a href='www.greenasap.com' class='green'>www.greenasap.com</a></strong> for new products and advice relating to green issues and property.</p><br/><br/>";
$strEmailbody .= "<p class='maintext'>The Green ASAP Team<br/>Green ASAP Ltd<br/><strong><a href='www.greenasap.com' class='purple'>www.greenasap.com</a></strong></p>";
$strEmailbody .= "<img src='http://www.mapsinternational.co.uk/nic_temp/footer.bmp'>";
$strEmailbody .= "</body></html>";

$emailSubject = "Your GreenASAP Order: " . $orderNo_ses;
//$emailDear1 = "Dear '" . $title.$fname ."".$sname. "',\r\n\r\n";
//$strEmailbody .= "Thank you for your order" ;
//$strEmailbody .= "Order No. ". $orderNo_ses . "\r\n";
//$strEmailbody .= "Order Details";
//$orderString = "[w[odfkcsdcmks;dlcm";
//$strEmailbody .= $orderString . "\r\n\r\n";
//$strEmailbody.= "Regards,\r\n";
//$strEmailbody .= "Wilbourn Associates";


//$emailDear1 = "Dear '" . $fname . "',\r\n\r\n";
//$emailBody .= "Thank you for your order" ;
//$emailBody .= "Order No. ". $orderNo_ses . "\r\n";
//$emailBody .= "Order Details";
//$orderString = "[w[odfkcsdcmks;dlcm";
//$emailBody .= $orderString . "\r\n\r\n";
//$emailBody .= "Regards,\r\n";
//$emailBody .= "Wilbourn Associates";

//$fullEmailBody = $emailDear1 . $emailBody;

$fullEmailBody = $strEmailbody ;

// To send HTML mail, the Content-type header must be set
//headers = "From: $from\r\n";
$emailHeaders = "MIME-Version: 1.0rn";
//$headers .= "Content-type: text/html; charset=iso-8859-1rn";
$emailHeaders .= "Content-Type'content='text/html; charset=iso-8859-1";



//***Send email to user and account admin where necessary.
$emailHeaders = 'From: ' . 'ADMIN_EMAIL';
if(mail($emailTo, $emailSubject, $fullEmailBody, $emailHeaders, '-f'.'ADMIN_EMAIL')){
}else{
echo "<p class='error' align='center'>There has been a problem sending your cofirmation email. <br/>Ensure your email address is correct or contact Wilbourn.</p>";
}
}

.......................
the result in inbox of this code is
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
<html><head><meta http-equiv='Content-Type'content='text/html; charset=iso-8859-1'><title>GreenAsap Order Confirmation</title><style type='text/css'><!--.maintext {font-family: Helvetica, Arial, sans-serif;size: 12pt;color:#000000}.green {font-family: Helvetica, Arial, sans-serif;size: 12pt;color:#85BC3F}.purple {font-family: Helvetica, Arial, sans-serif;size: 12pt;color:#00365A}.grey {font-family: Helvetica, Arial, sans-serif;size: 12pt;color:#808080}--></style></head><body><img src='http://www.mapsinternational.co.uk/nic_ ... er.bmp'><p class='maintext'>Dear Mr.LOVELL JOHN,</p><p class='maintext'>Report order: ASAP00000121</p><p class='maintext'>Thank you for ordering a <span class='green'><strong>Green</strong></span><span class='purple'><strong>Light</strong></span><span class='grey'><strong> Report</strong><sup>&reg;</sup></span>.Your report order will be shortly processed by one of our skilled Environmental Surveyors.<p class='maintext'>Remember to regularly check <strong><a href='www.greenasap.com' class='green'>www.greenasap.com</a></strong> for new products and advice relating to green issues and property.</p><br/><br/><p class='maintext'>The Green ASAP Team<br/>Green ASAP Ltd<br/><strong><a href='www.greenasap.com' class='purple'>www.greenasap.com</a></strong></p><img src='http://www.mapsinternational.co.uk/nic_ ... ody></html>

Re: i need help to send email containing html code by php

Posted: Tue Nov 18, 2008 8:09 am
by aceconcepts
Im not saying it will solve the problem at hand but you can only use inline style with html emails.

Re: i need help to send email containing html code by php

Posted: Tue Nov 18, 2008 8:14 am
by asifkamalzahid
i already tried this code with oout styles i mean just simple html code but it give me same error

Re: i need help to send email containing html code by php

Posted: Tue Nov 18, 2008 8:25 am
by aceconcepts
So what is exactly your problem?

Re: i need help to send email containing html code by php

Posted: Tue Nov 18, 2008 8:34 am
by asifkamalzahid
my problom is to execute my html code in inbox in order to show my reply.
i design the above code it need to work.
but i dont what is missing there ,it is not working

Re: i need help to send email containing html code by php

Posted: Tue Nov 18, 2008 9:06 am
by aceconcepts
These headers work perfectly for me:

Code: Select all

 
$from=me@moo.com";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "Content-Transfer-Encoding: 7bit\r\n";
$headers .= "From: " . $from . "\r\n";
 

Re: i need help to send email containing html code by php

Posted: Tue Nov 18, 2008 9:24 am
by asifkamalzahid
IS IT POSSIBLE THAT I CAN GET HELP FROM SOME ONE ,
THANKS

Re: i need help to send email containing html code by php

Posted: Tue Nov 18, 2008 9:25 am
by asifkamalzahid
IT IS SAME HEADERS WHAT I AM USING BUT REALY STRANGE WHY IT IS NOT WORKING ON MY CODE.

Re: i need help to send email containing html code by php

Posted: Tue Nov 18, 2008 9:27 am
by aceconcepts
They're not exactly the same. Notice the "\r\n"

Re: i need help to send email containing html code by php

Posted: Tue Nov 18, 2008 9:27 am
by asifkamalzahid
MMM OK I M GOING TO TRY

Re: i need help to send email containing html code by php

Posted: Tue Nov 18, 2008 10:29 am
by asifkamalzahid
i tried but sad ,not working

Re: i need help to send email containing html code by php

Posted: Tue Nov 18, 2008 10:30 am
by aceconcepts
is the only problem your formatting?

Re: i need help to send email containing html code by php

Posted: Tue Nov 18, 2008 10:52 am
by asifkamalzahid
done done done

thanks buddy you are right
i applied your code and it is working
thanks bro

Re: i need help to send email containing html code by php

Posted: Tue Nov 18, 2008 10:54 am
by asifkamalzahid
his code is become like this and working
thanks


// sending message after payment successfull
function sendemails($title,$fname,$sname,$email){


//varaibles
$orderNo_ses= $_SESSION['orderNo'];
$emailTo = $email;
$strCustomerName = $title . $fname . " " .$sname;
$strCurrentOrderNo = $orderNo_ses;



//fullbody message
$strEmailbody = "<html><head><meta http-equiv='Content-Type'content='text/html; charset=iso-8859-1'>";
$strEmailbody .= "<title>GreenAsap Order Confirmation</title>";
$strEmailbody .= "<style type='text/css'>";
$strEmailbody .= "<!--";
$strEmailbody .= ".maintext {font-family: Helvetica, Arial, sans-serif;size: 12pt;color:#000000}";
$strEmailbody .= ".green {font-family: Helvetica, Arial, sans-serif;size: 12pt;color:#85BC3F}";
$strEmailbody .= ".purple {font-family: Helvetica, Arial, sans-serif;size: 12pt;color:#00365A}";
$strEmailbody .= ".grey {font-family: Helvetica, Arial, sans-serif;size: 12pt;color:#808080}";
$strEmailbody .= "-->";
$strEmailbody .= "</style></head><body>";
$strEmailbody .= "<img src='http://www.mapsinternational.co.uk/nic_temp/header.bmp'>";
$strEmailbody .= "<p class='maintext'>Dear " . $strCustomerName . ",</p>";
$strEmailbody .= "<p class='maintext'>Report order: " . $strCurrentOrderNo . "</p>";
$strEmailbody .= "<p class='maintext'>Thank you for ordering a <span class='green'><strong>Green</strong></span><span class='purple'><strong>Light</strong></span><span class='grey'><strong> Report</strong><sup>&reg;</sup></span>.";
$strEmailbody .= "Your report order will be shortly processed by one of our skilled Environmental Surveyors.";
$strEmailbody .= "<p class='maintext'>Remember to regularly check <strong><a href='www.greenasap.com' class='green'>www.greenasap.com</a></strong> for new products and advice relating to green issues and property.</p><br/><br/>";
$strEmailbody .= "<p class='maintext'>The Green ASAP Team<br/>Green ASAP Ltd<br/><strong><a href='www.greenasap.com' class='purple'>www.greenasap.com</a></strong></p>";
$strEmailbody .= "<img src='http://www.mapsinternational.co.uk/nic_temp/footer.bmp'>";
$strEmailbody .= "</body></html>";


//subject
$emailSubject = "Your GreenASAP Order: " . $orderNo_ses;

//fullbody
$fullEmailBody = $strEmailbody ;


// To send HTML mail, the Content-type header must be set
$emailHeaders = "MIME-Version: 1.0\r\n";
$emailHeaders .= "Content-type: text/html; charset=iso-8859-1\r\n";
$emailHeaders .= "Content-Transfer-Encoding: 7bit\r\n";


//***Send email to user and account admin where necessary.
$emailHeaders .= "From: " . 'ADMIN_EMAIL' . "\r\n";


if(mail($emailTo, $emailSubject, $fullEmailBody, $emailHeaders, '-f'.'ADMIN_EMAIL')){
}else{
echo "<p class='error' align='center'>There has been a problem sending your cofirmation email. <br/>Ensure your email address is correct or contact Wilbourn.</p>";
}
}

Re: i need help to send email containing html code by php

Posted: Tue Nov 18, 2008 10:59 am
by aceconcepts
Good to hear :D