title: BAD HEADER: nonencoded 8-bit character issue
body: <p>I'm using PHP <code>mail()</code> to send e-mails with attached CSV file. My problem is that the server is putting some of these (most of them actually) mails in quarantine due to. According to the log the reason is:</p>
  
  <pre><code>mail.info:Sep  9 21:34:08 mailout4 amavis[18812]: (18812-05-2) Passed BAD-HEADER-2 {RelayedOpenRelay,Quarantined}, [xxx.xxx.xxx.xxx] &lt;xyz@ws15.surf-town.net&gt; -&gt; &lt;xyz@xyz.com&gt;, mail_id: skJU2BMP1ssu, Hits: 1.117, size: 5145, queued_as: BB1DE33018, 2571 ms
  
  BAD-HEADER-2 refers to: CC_BADH.',2',   "id=%n - BAD HEADER: nonencoded 8-bit  character",
  </code></pre>
  
  <p>So I'm thinking that this occurs due to some special chars in the CSV file data?</p>
  
  <p>The code sending the mail looks like this (there are more code, but this shows you the mail header, etc).</p>
  
  <pre><code>//create attachment from array of data $csvdata
  $attachment = chunk_split(base64_encode(create_csv_string($csvData,$filename))); 
  
  // Make the body of the message
  $body = "--$multipartSep\r\n"
      . "Content-Type: text/plain; charset=utf-8; format=flowed\r\n"
      . "Content-Transfer-Encoding: 7bit\r\n"
      . "\r\n"
      . "$body\r\n"
      . "--$multipartSep\r\n"
      . "Content-Type: text/csv\r\n"
      . "Content-Transfer-Encoding: base64\r\n"
      . "Content-Disposition: attachment; filename=\"$filename\"\r\n"
      . "\r\n"
      . "$attachment\r\n"
      . "--$multipartSep--";
  
   $subject .= ' (' . date('Y-m-d H:i:s') . ')';
  
   $headers = array(
     "From: $from",
     "Reply-To: $from",
     "Content-Type: multipart/mixed; boundary=\"$multipartSep\""
   );   
  
   $recievers = explode(','.$to);
   foreach ($recievers as $reciever) {
     mail($reciever, $subject, $body, implode("\r\n", $headers)); 
   }
  </code></pre>
  
  <p>Has any of you encountered this problem?</p>
  
  <p>Any ideas on a fix that doesn't require changing the server setup?</p>