第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

三次方碼:郵件附件為空

三次方碼:郵件附件為空

PHP
皈依舞 2022-09-25 20:57:36
我正在使用 TCPDF 創(chuàng)建配置文件并將配置文件作為附件發(fā)送。我有許多客戶使用該軟件,并且需要批量電子郵件服務。我一直在從本地服務器電子郵件發(fā)送配置文件,它工作得很好。這是以前的代碼(只是電子郵件部分):$pdf->writeHTML($tbl, true, false, false, false, '');$js .= 'print(true);';// set javascript$pdf->IncludeJS($js); //Close and output PDF document//Close and output PDF document//define the receiver of the email$to = $Email;$subject = "Profile";$repEmail = 'me@mydomain.com';$fileName = 'Profile.pdf';$fileatt = $pdf->Output($fileName, 'S');$attachment = chunk_split(base64_encode($fileatt));$eol = PHP_EOL;$separator = md5(time());$headers = 'From: Identykidz <'.$repEmail.'>'.$eol;$headers .= 'MIME-Version: 1.0' .$eol;$headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"";$message = "--".$separator.$eol;$message .= "Content-Transfer-Encoding: 7bit".$eol.$eol;$message .= "Dear parent/guardian  \r\n\r\nPlease find attached the Profile attached.Kind regards\r\nIdentyKidz Information Centre".$eol;$message .= "--".$separator.$eol;$message .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;$message .= "Content-Transfer-Encoding: 8bit".$eol.$eol;$message .= "--".$separator.$eol;$message .= "Content-Type: application/pdf; name=\"".$fileName."\"".$eol; $message .= "Content-Transfer-Encoding: base64".$eol;$message .= "Content-Disposition: attachment".$eol.$eol;$message .= $attachment.$eol;$message .= "--".$separator."--";// Send the emailif(mail($to, $subject, $message, $headers)) {echo '<span style="color:#1e73be; text-align: center; font-family: Verdana">The profile has been sent successfully to the email address entered.</span>';}else {echo "There was an error sending the mail.";}}//catch exceptioncatch(Exception $e) {header("Location: something_went_wrong.php");}//============================================================+// END OF FILE//============================================================+因為我需要使用批量電子郵件服務,所以我必須包括批量電子郵件服務提供商的SMTP詳細信息,所以我將TCPDF的電子郵件部分從mail()更改為PHPMailer。
查看完整描述

4 回答

?
瀟瀟雨雨

TA貢獻1833條經(jīng)驗 獲得超4個贊

你好查爾斯瓦辛頓,我已經(jīng)檢查了你的代碼示例:


根據(jù)您的代碼,我看到您正在嘗試從字符串加載文件。


這讓我有點困惑,因為我立即收到一個錯誤。您是否已啟用并檢查了日志?無論如何,你只需要將字符串放入正確的變量中,其他一切都可以正常工作。您可以在下面找到我對您的代碼所做的更改。error_reportingerror_log


以前:


$fileatt = $pdf->Output('Profile.pdf', 'S'); // S = Means return the PDF as string

// ... code ... 

$pdf_content = file_get_contents($fileatt);

// .. code

$mail->AddStringAttachment($pdf_content, "Prodile.pdf", "base64", "application/pdf");

后:


$pdf_content = $pdf->Output('Profile.pdf', 'S'); 

// ... code ... 

$mail->AddStringAttachment($pdf_content, "Prodile.pdf", "base64", "application/pdf");

我剛剛使用 SES 憑據(jù)和自定義 PDF 以及以前生成的 PDF 測試了您的腳本。


如果這有幫助,請告訴我。


查看完整回答
反對 回復 2022-09-25
?
紫衣仙女

TA貢獻1839條經(jīng)驗 獲得超15個贊

通過使用


$fileatt = $pdf->Output('Profile.pdf', 'S');

//I have also tried $fileatt = $pdf->Output('Profile.pdf', 'I');


require ('PHPMailer/PHPMailerAutoload.php');


$pdf_content = file_get_contents($fileatt);

您正在嘗試從字符串中讀取file_content。


您只需通過以下方式發(fā)送附件


 $mail->AddStringAttachment($fileatt, "Prodile.pdf", "base64", "application/pdf");  


查看完整回答
反對 回復 2022-09-25
?
元芳怎么了

TA貢獻1798條經(jīng)驗 獲得超7個贊

我想也許你必須依戀。請參閱此處,第一個答案:base64_decode

$mail->AddStringAttachment(base64_decode($pdf_content), "Prodile.pdf", "base64", "application/pdf");

的第三個參數(shù)僅告訴編碼,但顯然不會為您執(zhí)行任何編碼。AddStringAttachment


查看完整回答
反對 回復 2022-09-25
?
忽然笑

TA貢獻1806條經(jīng)驗 獲得超5個贊

我能夠根據(jù)ivion的評論對問題進行排序。

$mail->AddStringAttachment($fileatt, "Prodile.pdf", "base64", "application/pdf");


查看完整回答
反對 回復 2022-09-25
  • 4 回答
  • 0 關注
  • 128 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號