我正在开发一个打开表单现有图像的脚本,并填写表单。我输入了在表单中编写文本所需的所有代码。问题是我正在尝试将修改后的图像发送到电子邮件。我正在使用GD库ImageCreate,ImageCopy和ImageJPEG。但是,不是保存图像,而是通过电子邮件发送表单。这是我到目前为止所得到的
$tempname = "forms/temp".mt_rand().".jpg";
imagejpeg($image, $tempname);
$datamsg = chunk_split(base64_encode(file_get_contents($tempname)));
$uid = md5(uniqid(time()));
$message = "Please see attachment for your form";
$emailheader = "From: email@address.com\r\n";
$emailheader .= "Reply-To: email@address.com \r\n";
$emailheader .= "MIME-Version: 1.0\r\n";
$emailheader .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n";
$emailheader .= "This is a multipart message in Mime-Format\r\n";
$emailheader .= "--" .$uid."\r\n";
$emailheader .= "Content-Type: text/plain;\r\n";
$emailheader .= "Content-Transfer-Encoding: 7bit\r\n";
$emailheader .= $message ."\r\n";
$emailheader .= "--" .$uid."\r\n";
$emailheader .= "Content-Type: Image/JPEG;name=\"jtstemp.jpg\"\r\n";
$emailheader .= "Content-Transfer-Encoding: base64\r\n";
$emailheader .= "Content-Disposition: attachment; Filename=\"jtstemp.jpg\"\r\n";
$emailheader .= $datamsg."\r\n";
if(mail("recipient@address.com", "Sample Subject", "", $emailheader)){
echo "success";
}else{
echo "failure";
}
电子邮件已注册为附件,但它是空白的。此外,普通的测试信息也没有显示出来。
答案 0 :(得分:0)
我真的建议你使用为它构建的库。
你会比试图自己重新完成工作更快地完成工作。