我正在将用户上传的图像和PDF文件保存在本地路径之一中。现在,我想在邮寄邮件时附上这些PDF和图像文件[邮件 - 使用POSTMARK API]。但它没有被附加。邮戳 - 无法从Symfony2中保存的位置路径附加PDF和图像
下面是我使用的代码 -
//Location where the file gets uploaded
$targetPath = $this->container->getParameter('upload_dir').'/Exibition/'.$fileName;
$imagePath = $this->container->getParameter('upload_dir').'/sk_booth_B17.jpg';
$message = $this->get('postmark.message');
$message->addTo($custemail);
$message->addCC($userEmail);
$message->setSubject('My Subject Goes Here');
$message->setHTMLMessage($message_body);
$message->addAttachment($targetPath);
$message->addAttachment($imagePath);
$result = $message->send();
if($result){
// Do Something
}else{
// Do Something
}
我已经正确做好了所有的配置。我能够发送纯文本邮件,无需任何附件。
当我试图附加PDF或图片我收到以下错误 -
捕致命错误:传递给MZ \ PostmarkBundle \邮戳\消息参数1 :: addAttachment()必须是Symfony的实例\ Component \ HttpFoundation \ File \ File,给出的字符串,在C:\ wamp \ www \ skerp4 \ src \ Skerp \ SalesBundle \ Controller \ ExhibitionCustomerController.php中调用,并在C:\ wamp \ www \ skerp4 \ vendor中定义\ mlpz \ postmark-bundle \ MZ \ PostmarkBundle \ Postmark \ Message.php line 254
如何附加本地保存的PDF或Images.Where我会出错。如何实现附件。任何帮助将appriciated。
为什么你不使用SwiftMailer?邮戳是否必要?什么是PDF和图像的组合大小? Postmark docs说:“最大电子邮件大小为10 MB,包括电子邮件内容,标题和附件,如果您的电子邮件太大,您将收到错误信息。”但是我再次问,为什么在使用更好的SwiftMailer库[和Postmark的SMTP协议](http://developer.postmarkapp.com/developer-send-smtp.html)时使用API? – sjagr 2014-11-05 18:55:27
当我使用SwifMailer时,我的邮件开始进入Gmail中的垃圾邮件文件夹。所以我使用Postmaster API – 2014-11-06 03:51:17