**Update: Updated the code and added the email contents as seen in Gmail. **
I have a problem which I've been trying to solve a couple of days. But since I have been unable to make any progress, I'd like the help of someone else. I'm trying to send a zip file from my server to my email. However, the email is being sent empty. This is the code:
`$headers = "From: $from";
/* Generate boundary string */
$random = md5(time());
$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random."\"";
/* Read the file */
$attachment = chunk_split(base64_encode(file_get_contents("backup-$date-$time-9.zip")));
/* Define body */
$message = "--PHP-mixed-$random
Content-Type: text/plain; charset=\"iso-8859-1\"
Attached, please find your backup file.
--PHP-mixed-$random
Content-Type: application/zip; name=backup-$date-$time-9.zip
Content-Transfer-Encoding: base64
Content-Disposition: attachment
$attachment
--PHP-mixed-$random--"; // no intendation
$mail = mail($email, $subject, $message, $headers);
echo $mail ? "Email sent<br>" : "Email sending failed<br>";`
Thanks to all reading and wanting to help.
The resulting email as seen in Gmail is
Attached, please find your backup file.
--PHP-mixed-e44b531b0e0538185289abc521eda78d
Content-Type: application/zip; name=backup-29-11-2014-1417275285-9.zip
Content-Transfer-Encoding: base64
Content-Disposition: attachment
UEsDBBQAAAAIAFZ8fUUs...sUEsFBgAAAAACAAIAeAAAAD4B
AAAAAA==
--PHP-mixed-e44b531b0e0538185289abc521eda78d--