相关疑难解决方法(0)

使用FPDF通过PHP向PDF附件发送电子邮件

我想通过电子邮件发送PDF作为使用FPDF创建的附件.我的代码看起来像这样,但附件永远不会出现.

<?php
require('lib/fpdf/fpdf.php');

$pdf = new FPDF('P', 'pt', array(500,233));
$pdf->AddFont('Georgiai','','georgiai.php');
$pdf->AddPage();
$pdf->Image('lib/fpdf/giftcertificate.jpg',0,0,500);
$pdf->SetFont('georgiai','',16);
$pdf->Cell(40,10,'Hello World!');
$doc = $pdf->Output('test.pdf', 'S');

//define the receiver of the email
$to = 'myemail@example.com';
//define the subject of the email
$subject = 'Test email with attachment';
//create a boundary string. It must be unique
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time()));
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: reply@test.com\r\nReply-To: …
Run Code Online (Sandbox Code Playgroud)

php pdf attachment fpdf

15
推荐指数
2
解决办法
6万
查看次数

标签 统计

attachment ×1

fpdf ×1

pdf ×1

php ×1