我正在將用戶上傳的圖像和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