title: Sending fpdf attachments does not work on my linux suse server but it does on my shared hosting account
body: <p>I have a php program i have developed on the internet. So far i have used a shared hosting package. Everything worked until i moved to a vps (apache2 suse 9.1 plesk) . I have found certain php functions have not been activated. I have solved most of them by using the internet.</p>
  
  <p>My main problem is emailing pdfs with fpdf. i.e</p>
  
  <pre><code>&lt;?php
  // download fpdf class (http://fpdf.org)
  require("fpdf.php");
  
  // fpdf object
  $pdf = new FPDF();
  
  // generate a simple PDF (for more info, see http://fpdf.org/en/tutorial/)
  $pdf-&gt;AddPage();
  $pdf-&gt;SetFont("Arial","B",14);
  $pdf-&gt;Cell(40,10, "this is a pdf example");
  
  // email stuff (change data below)
  $to = "steven@siteaddress.co.uk"; 
  $from = "me@domain.com"; 
  $subject = "send email with pdf attachment"; 
  $message = "&lt;p&gt;Please see the attachment.&lt;/p&gt;";
  
  // a random hash will be necessary to send mixed content
  $separator = md5(time());
  
  // carriage return type (we use a PHP end of line constant)
  $eol = PHP_EOL;
  
  // attachment name
  $filename = "example.pdf";
  
  // encode data (puts attachment in proper format)
  $pdfdoc = $pdf-&gt;Output("", "S");
  $attachment = chunk_split(base64_encode($pdfdoc));
  
  
  // main header (multipart mandatory)
  $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;
  
  // message
  $headers .= "--".$separator.$eol;
  $headers .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
  $headers .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
  $headers .= $message.$eol.$eol;
  
  // attachment
  $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."--";
  
  // send message
  //mail($to, $subject, "", $headers);
  if (@mail($to, $subject, "",$headers)) {  
   echo('&lt;p&gt;Mail sent successfully.&lt;/p&gt;');  
  } else {  
   echo('&lt;p&gt;Mail could not be sent.&lt;/p&gt;');  
  }  
  
  ?&gt;
  </code></pre>
  
  <p>The file above works on my share hosting , but when it comes to sending from my vps i get this error message from my file</p>
  
  <pre><code>Mar 23 19:16:56 h1871885 suhosin[64630]: ALERT - mail() - double newline in headers, possible injection, mail dropped (attacker '86.137.40.199', file '/srv/www/vhosts/sitename.co.uk/httpdocs/main/email.php', line 111)
  </code></pre>
  
  <p>after much trial, the error is from this line</p>
  
  <pre><code> if (@mail($to, $subject, "",$headers))
  </code></pre>
  
  <p>If i remove the "", it sends the email on my vps but there is no attachment. this also happens on my shared account. The attachment ends up in the message with a hole load of chars'. 
  So i def need them in there. does anyone have a clue how to overcome this problem.</p>
  
  <p>many thanks </p>
  
  <p>after setting suhosin.ini to 0</p>
  
  <pre><code>Mar 23 20:52:48 h1871885 suhosin[60778]: ALERT - mail() - double newline in headers, possible injection, mail dropped (attacker '86.137.40.199', file '/srv/www/vhosts/sitename.co.uk/httpdocs/main/email1.php', line 56)
  </code></pre>