0

i am sending email with attached pdf file. when i am using plex panel below code is working fine now i updated with Cpanel this script could not work. below is code of email

$to = $email.",billing@hotelsinkonkan.in"; 
$from = "billing@hotelsinkonkan.in"; 
$subject ="Instant e-Bill from www.hotelsinkonkan.in for ".$hotel_name; 


$message ="<html><head></head><body style='font-family:Calibri; font-size:11pt; line-height:18px; color:#403437;'>";

$message .="Dear ".$contact.",<br/><br/>";

$message.="<p style='font-size:15px; color:#215868' >Thank you for being our Valued Customer and for using Instant e-Bill service.!</p>";

$message.="We are pleased to present your e-Bill for Advertise on www.hotelsinkonkan.in dated <strong>".date("d-m-y")."</strong> for the period ".$st_date1.' To '.$ed_date1."<br/>";

$message.="<p style='font-size:15px; color:#215868'>We value your relationship with us and assure you our best services at all times.</p>";

$message .="Thanks And Regards<br/>
Billing Hotels In Konkan<br/>
(Active Bit Technologies)<br/>";

$message.="<img style='margin:10px 0px 10px 0px;' src='http://hotelsinkonkan.in/admin/images/logo_mail.jpg'/><br/>";

$message .="Address - Dhayari Industrial Estate,<br/>
Near Pari Automation, Starling<br/>
Nisarga Phase ||, Dhayari<br/><br/>";

$message .="<p style='color:#292727'>Phone no : +91 020 - 32326630</p>";

$message .="<p>Website   : www.hotelsinkonkan.in<br/>";
$message .="Email : billing@hotelsinkonkan.in</p>";

$message .="Click Here to Download Hotels in Konkan <a href='http://slideme.org/application/hotelsinkokan'>Apps on Your Mobile</a><br/>"; 

$message.="<img style='margin:10px 0px 6px 0px;' src='http://hotelsinkonkan.in/admin/images/mail.jpg'/><br/>";

$message.="MPORTANT NOTICE:<br/>
Internet communications cannot be guaranteed to be timely, secure, error or virus-free. The sender, does not accept liability for any errors or omissions. Active Bit Technologies does not accept liability of mishandling of email account. The information in this email (and any attachments) is confidential. If you are not the intended recipient, you must not use or disseminate this information. If you have received this email in error, please immediately revert to support@activebittechnologies.com  and permanently delete the original and any copies or printouts thereof. Although this email and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by Active Bit Technologies. or their subsidiaries or affiliates either jointly or severally, for any loss or damage arising in any way from its use.";

$message .="</body></html>";

 echo $message;
$separator = md5(time());

$eol = PHP_EOL;

$filename =$pdf_name.".pdf";

$pdfdoc = $pdf->Output("", "S");
$attachment = chunk_split(base64_encode($pdfdoc));



$headers  = "From: ".$from.$eol;
$headers .= "MIME-Version: 1.0".$eol; 
$headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"".$eol.$eol; 
$headers .= "Content-Transfer-Encoding: 7bit".$eol;
$headers .= "This is a MIME encoded message.".$eol.$eol;



$headers .= "--".$separator.$eol;
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
$headers .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$headers .= $message.$eol.$eol;


$headers .= "--".$separator.$eol;
$headers .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol; 
$headers .= "Content-Transfer-Encoding: base64".$eol;
$headers .= "Content-Disposition: attachment".$eol.$eol;
$headers .= $attachment.$eol.$eol;
$headers .= "--".$separator."--";


mail($to, $subject, "", $headers);

========================================================================

Vivek
  • 47
  • 6
  • What means "Does not work"? Any Errors? – Twinfriends Apr 21 '17 at 08:21
  • check your error_logs. turn on `error_reporting(E_ALL)`. Something is there – Rotimi Apr 21 '17 at 08:23
  • no sir i dont getting any error mail not delivered – Vivek Apr 21 '17 at 08:25
  • mail($to, $subject, "", $headers); i am using this after remove mail($to, $subject, $headers); mail is delivering but it display all in code language – Vivek Apr 21 '17 at 08:26
  • use something like PHP Mailer or SwiftMailer if you have the chance it will be easier not manually writing the headers.. you need to check the raw mail headers of the email you received, probably something is wrong or not in proper format. – Gntem Apr 21 '17 at 08:34
  • but sir on my old Plex server same code is working i updated it before 15 days then it will not working – Vivek Apr 21 '17 at 08:39

0 Answers0