When adding a file you must open it and read it with fopen and add the content to the message:<?php$path = "whatever the path to the file is";$fp = fopen($path, 'r');do //we loop until there is no data left{ $data = fread($fp, 8192); if (strlen($data) == 0) break; $content .= $data; } while (true);$content_encode = chunk_split(base64_encode($content));$message .= $content_encode . "\n";$message .= "--" . $boundary . "\n";?>