我使用PHP郵件發送pdf中的發票。 PDF是使用tcpdf插件attatchment生成的,不能分配到郵件我使用以下代碼 請幫助我,我該怎麼辦?使用由tcpdf生成的Phpmailer發送PDF文件
$pdf->writeHTML($html, true, false, false, false, '');
$pdf->Output($pdf_name, 'I');
$filename =$pdf_name.".pdf";
$pdfdoc = $pdf->Output("invoice.pdf", "S");
$attachment = chunk_split(base64_encode($pdfdoc));
require_once('class.phpmailer.php');
define('GUSER', '[email protected]');
define('GPWD', 'xxx');
$subject ="Instant e-Bill from for ".$hotel_name;
function smtpmailer($to, $from, $from_name, $subject, $body)
{
global $error;
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Host ="mail.activebittechnologies.com";
$mail->port =25;
$mail->Username = GUSER;
$mail->Password = GPWD;
$mail->SetFrom($from, $from_name);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAttachment($attachment);
$mail->AddAddress($to);
if(!$mail->Send()) {
$error = "Mail error: ".$mail->ErrorInfo;
return false;
} else {
$error = "Message sent!";
return true;
}
}
$message ="Booking enquiry form www.hotelsinkonkan.in";
smtpmailer("[email protected]","[email protected]","Invoice Form hotelsinkonkan",$subject,$message);
[如何使用TCPDF與PHP郵件功能]可能重複(http://stackoverflow.com/questions/11571977/how-to-use-tcpdf-with-php-mail-function) – Synchro