Php zend邮件附件不工作
我在我的网站上使用zend mail进行邮寄。在这封邮件中,我添加了一个图像附件功能。邮件已成功发送,但我无法从收件箱查看图像。他们说那是不受支持的文件格式 这是我的密码Php zend邮件附件不工作,php,zend-framework,zend-mail,Php,Zend Framework,Zend Mail,我在我的网站上使用zend mail进行邮寄。在这封邮件中,我添加了一个图像附件功能。邮件已成功发送,但我无法从收件箱查看图像。他们说那是不受支持的文件格式 这是我的密码 $attach_path = image path $transport = new Zend_Mail_Transport_Smtp('sanple', $config); $mail = new Zend_Mail('UTF-8'); $mail->setBodyHt
$attach_path = image path
$transport = new Zend_Mail_Transport_Smtp('sanple', $config);
$mail = new Zend_Mail('UTF-8');
$mail->setBodyHtml($message);
$fileContents = file_get_contents($attach_path);
$at = $mail->createAttachment($fileContents);
$at->type = 'image/jpeg';
$at->filename = 'test.jpg';
$mail->setFrom('customersupport@testing.com', 'customersupport@testing.com');
$mail->addTo('customersupport@testing.com','customersupport@testing.com');
$mail->setSubject($subject);
$mail->send($transport);
如果这有什么问题,请帮帮我
提前感谢。如果您查看文档,您会看到它们设置了处置和编码
请尝试以下代码
$content = file_get_contents($attach_path);
$attachment = new Zend_Mime_Part($content);
$attachment->type = 'image/jpeg';
$attachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
$attachment->encoding = Zend_Mime::ENCODING_BASE64;
$attachment->filename = 'test.jpeg';
$mail->addAttachment($attachment);
您的文件是.gif图像,但mime类型是jpeg,请尝试使用$at->type=“image/gif”这是我的错误。当我从另一个部分复制时,类型发生了变化。但这对我没有帮助。感谢您在这方面给予我的答复,
$content = file_get_contents($attach_path);
$attachment = new Zend_Mime_Part($content);
$attachment->type = 'image/jpeg';
$attachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
$attachment->encoding = Zend_Mime::ENCODING_BASE64;
$attachment->filename = 'test.jpeg';
$mail->addAttachment($attachment);