473,386 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Mail pdf attachment gets file corrupted

I'm facing problem with mail pdf attachment gets file corrupted. When we click on the attachment "Adobe reader could not open xx.pdf because it is either not a supported file type or because the file has been damaged(for example, it was send as an email attachment and wasn't correctly decoded)" error message is showing. Below is my email attachment code.
Expand|Select|Wrap|Line Numbers
  1. $companyinfo = "xxxx";
  2.      $ccinfoges = "test";
  3.      $message = "test message";
  4.     include("test/mpdf/mpdf.php");
  5.             $mpdf=new mPDF();   
  6.             $mpdf->ignore_invalid_utf8 = true;
  7.             $stylesheet = file_get_contents('appstyle_pdf.css');
  8.  
  9.             $mpdf->WriteHTML($stylesheet,1);
  10.             $mpdf->WriteHTML($output);
  11.  
  12.  
  13.             $comname = preg_replace("/[^A-Za-z0-9]/","",$_POST['company']);  
  14.  
  15.             $name = $dirname.str_replace(" ","-",$comname)."_".$time_stamp.".pdf";        
  16.             $mpdf->Output($name,"F"); 
  17.             $file = $name;
  18.             $crlf = "\n";
  19.  
  20.             $filename = basename($file);
  21.             $file_size = filesize($file);
  22.             $content = chunk_split(base64_encode(file_get_contents($file))); 
  23.             $uid = md5(uniqid(time()));
  24.  
  25.             $headers = "\r\n"
  26.                   ."MIME-Version: 1.0\r\n"
  27.                   ."Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n"
  28.                   ."This is a multi-part message in MIME format.\r\n" 
  29.                   ."--".$uid."\r\n"
  30.                   ."Content-type:text/plain; charset=iso-8859-1\r\n"
  31.                   ."Content-Transfer-Encoding: 7bit\r\n\r\n"
  32.                   .$message." 
  33.                   ".$companyinfo." 
  34.                   ".$ccinfoges."\r\n\r\n"
  35.                   ."--".$uid."\r\n"
  36.                   ."Content-Type: application/octet-stream; name=\"".$filename."\"\r\n"
  37.                   ."Content-Transfer-Encoding: base64\r\n"
  38.                   ."Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n"
  39.                   .$content."\r\n\r\n"
  40.                   ."--".$uid."--";
  41.         mail($testmail, $subject, "$message \f $companyinfo $ccinfoges", $headers);
when sending the attachment to Gmail it's working fine some of the domains pdf file is corrupted.We are using windows server. What could possibly be happening? Any help ?
Feb 20 '15 #1
0 1194

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Larry Viezel | last post by:
I have a string: sring Result = "This is the string I want sent as a text file" I have MailMessage: MailMessage TestMail = new MailMessage(); TestMail.From = "larry.viezel@tmp.com";...
1
by: Fraser S | last post by:
Hi, I am receiving an invalid mail Attachment error when trying to send an attachment using System.Web.Mail. I have read other posts on these errors and have since checked that the asp.net account...
2
by: bmcelhany | last post by:
Hello, I'm developing a windows service that monitors a directory (using a FileSystemWatcher) for newly created files. When a new file is created, I need to generate an e-mail and send that file...
2
by: GD | last post by:
Hi, An intranet application, with a SMTP mail function that lets users to attach files with emails by selecting files in their local computers (through a file browser component), works perfect on...
1
by: theWizard1 | last post by:
The following sends my email, but the attachment is empty. The attachment should contain the data that is in the string that was created from the xmlReader. I have a stored procedure written...
2
by: Ray | last post by:
Hi Can anyone help with something that has beaten me. I am sending an email with an attachment, as per below. If I comment out the MailAttachment line then the mail gets sent, but with it in I...
8
by: =?Utf-8?B?cm95SGU=?= | last post by:
I have a web service. It creates a email and attached a file sitting one the network drive \\servername\filename. I tried UNC format and also try to mapping drive (eg. g:\text.txt or...
0
by: kencana | last post by:
Hi all, I got problem in sending email with image file attached. the problem is that i can't see the image, apart from that i also try to attach a txt file and it gave me no luck. the txt file in...
1
by: vinodkus | last post by:
dear sir/maadm I have to send a mail attachment but my problem is that file name of my attachment should be changed that i will write in a text box. please suggest any solution Thanks in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.