我已经编辑了这个脚本来处理我需要它的东西,它仍然像它应该发送的那样 - 尽管我得到的只是“Body”$message
然后是一大堆随机字母永远......
我不知道我可能做错了什么,但你应该知道一些事情......
$photo
类似于:SOTT_photos/Plymouth/290416/unio/a290416789.JPG
所以我不能只获得图像名称,这就是我使用Myphoto.jpg
的原因,虽然我看不出会导致这种错误?
照片也可以是JPG,jpg,PNG,png等...所以我需要考虑所有可能大写或不大写的图像类型。
$subject = 'My SmileontheTiles Photo!';
$from = 'info@SmileontheTiles.com';
$body = $message;
$photoPath = $photo;
$photoName = 'Myphoto.jpg';
$filetype = 'image/JPG';
$bound_text = md5(uniqid(rand(), true));;
$bound = "--" . $bound_text . "\r\n";
$bound_last = "--" . $bound_text . "--\r\n";
$headers = "From:" . $from . "\r\n"
. "MIME-Version: 1.0\r\n"
. "Content-Type: multipart/mixed; boundary=\"$bound_text\"";
$message = "Sorry, your client doesn't support MIME types.\r\n"
. $bound;
$message .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n"
. "Content-Transfer-Encoding: 7bit\r\n\r\n"
. $body
. $bound;
$file = file_get_contents($photoPath);
$message .= "Content-Type: $filetype; name=\"$photoName\"\r\n"
. "Content-Transfer-Encoding: base64\r\n"
. "Content-disposition: attachment; file=\"$photoName\"\r\n"
. "\r\n"
. chunk_split(base64_encode($file))
. $bound_last;
mail($emails, $subject, $message, $headers);
我看不出这里可能出现的问题,但也许其他人可以帮助我?
P.S - 我知道额外的标题现在有安全风险,虽然我不确定如何弥补这一点?