Attachment mail using php mail()?
<p>This is the code snippet i am using to send an email with attachment,but it is not working.The output i am getting includes a large amount of hashcode(i think so).What should be done to send screenshot.rar as attachment ?   </p>

<pre><code>&lt;?php

      $to = "abc@gmail.com";

      $subject = "A test email";

      $random_hash = md5(date('r', time()));

      $headers = "From: xyz@gmail.com\r\n";

      $headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";

      $attachment = chunk_split(base64_encode(file_get_contents("screenshot.rar")));

      $output = "
      --PHP-mixed-$random_hash
      Content-Type: multipart/alternative; boundary='PHP-alt-$random_hash'
      --PHP-alt-$random_hash
      Content-Type: text/plain; charset='iso-8859-1'
      Content-Transfer-Encoding: 7bit

      Hello World!
      This is the simple text version of the email message.

      --PHP-alt-$random_hash
      Content-Type: text/html; charset='iso-8859-1'
      Content-Transfer-Encoding: 7bit

      &lt;h2&gt;Hello World!&lt;/h2&gt;
      &lt;p&gt;This is the &lt;b&gt;HTML&lt;/b&gt; version of the email message.&lt;/p&gt;

      --PHP-alt-$random_hash--

      --PHP-mixed-$random_hash
      Content-Type: application/zip; name=screenshot.rar
      Content-Transfer-Encoding: base64
      Content-Disposition: attachment

      $attachment
      --PHP-mixed-$random_hash--";

      echo @mail($to, $subject, $output, $headers);

    ?&gt;
</code></pre>
