Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to set the right mail-headers, and then attach the file by encoding it to whatever form you have declared in the header, like in this snippet: </p> <p>All you need to do here, is read the file, and encode it (to base64 in this case)</p> <pre><code>$file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); $data = chunk_split(base64_encode($data)); </code></pre> <p>first you'll need a boundary, like a rule to tell where one part stops, and the other begins</p> <pre><code>$semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; </code></pre> <p>then set the headers right, to support attachement</p> <pre><code>$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; </code></pre> <p>then build up your message</p> <pre><code>$email_message .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . // start text block "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_content . "\n\n" . "--{$mime_boundary}\n" . // start attachement "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . // this is the file... "--{$mime_boundary}\n"; </code></pre> <p>and then... sent the message using mail ;-)</p> <pre><code>mail($email_to, $email_subject, $email_message, $headers) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload