FPDF와 PHPMailer 코드를 병합하거나 링크하여 문서가 생성되고 전자 메일로 전송되도록하고 싶습니다. 파일을 저장하고 싶지 않습니다. 솔루션을 찾을 수 없습니다. 아래는 FPDF 및 PHPMailer의 작업 코드입니다. 두 항목을 병합 할 수 없습니다.PHPMailer를 사용하여 FPDF 문서를 보내려면 어떻게합니까?
FPDF 웹 사이트는이
$mail = new PHPMailer();
...
$doc = $pdf->Output('', 'S');
$mail->AddStringAttachment($doc, 'doc.pdf', 'base64', 'application/pdf');
$mail->Send();
FPDF 코드를 이렇게 말한다 :
require_once('fpdf/fpdf.php');
$fpdf = new FPDF();
$text="test";
$fpdf->SetMargins(0, 0, 0);
$fpdf->SetAutoPageBreak(true, 0);
define('FPDF_FONTPATH', 'font/');
$fpdf->AddFont('Verdana', '','verdana.php'); // Standard Arial
$fpdf->addPage('L');
$fpdf->Image('images/certificate.jpg', 0, 0, 297, 210);
$fpdf->SetFont('Verdana', '');
$fpdf->SetFontSize(28);
$fpdf->SetTextColor(32, 56, 100);
$fpdf->SetXY(108, 52); //
$fpdf->Cell(80, 6, $text, 0,0, 'C');
$fpdf->Output('Filename.pdf', 'i');
PHPMailer 코드 :
require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->IsSMTP(); // Set mailer to use SMTP
$mail->Host = 'gator3095'; // Specify main and backup server
$mail->Port = 587; // Set the SMTP port
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'username'; // SMTP username
$mail->Password = 'password'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
$mail->From = '[email protected]';
$mail->FromName = 'John Doe';
$mail->AddAddress('[email protected]', ''); // Add a recipient
$mail->IsHTML(true); // Set email format to HTML
$mail->Subject = 'subject';
$mail->Body = 'message body';
$mail->AltBody = 'messge body';
$mail->AddAttachment("c:/temp/test.php", "test.php");
if(!$mail->Send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
echo 'Message has been sent';