Using mail() to send an attachment AND text/html in an email in PHP4 <p>To make life difficult, the client I'm working for is using a really large yet old system which runs on PHP4.0 and they're not wanting any additional libraries added.</p> <p>I'm trying to send out an email through PHP with both an attachment and accompanying text/html content but I'm unable to send both in one email.</p> <p><strong>This sends the attachment:</strong></p> <pre><code>$headers = "Content-Type: text/csv;\r\n name=\"result.csv\"\r\n Content-Transfer-Encoding: base64\r\n Content-Disposition: attachment\r\n boundary=\"PHP-mixed-".$random_hash."\""; $output = $attachment; mail($emailTo, $emailSubject, $output, $headers); </code></pre> <p><strong>This sends text/html:</strong></p> <pre><code>$headers = "Content-Type: text/html; charset='iso-8859-1'\r\n"; $output = $emailBody; // $emailBody contains the HTML code. </code></pre> <p><strong>This sends an attachment containing the text/html along with the attachment contents:</strong></p> <pre><code>$headers = "Content-Type: text/html; charset='iso-8859-1'\r\n".$emailBody."\r\n"; $headers = "Content-Type: text/csv;\r\n name=\"result.csv\"\r\n Content-Transfer-Encoding: base64\r\n Content-Disposition: attachment\r\n boundary=\"PHP-mixed-".$random_hash."\""; $output = $attachment; </code></pre> <p>What I need to know is how can I send an email with text/html in the email body and also add an attachment to it. I'm sure I'm missing something really simple here!</p> <p>Thanks in advance.</p>