php邮件http附件,php发送带有PDF附件的电子邮件

我正在使用

FPDF创建pdf. Pdf正在完美生成,pdf也可以通过电子邮件发送.但我也想发送正文消息.我尝试过身体信息.示例精细文本消息这是来自shohag的文本消息但只有pdf附件可用且正文为空.这是我的代码.

function send_pdf_to_user(){

if($_REQUEST['action'] == 'pdf_invoice' ){

require('html2pdf.php');

$pdf=new PDF_HTML();

$pdf->SetFont('Arial','',11);

$pdf->AddPage();

$text = get_html_message($_REQUEST['eventid'], $_REQUEST['userid']);

if(ini_get('magic_quotes_gpc')=='1')

$text=stripslashes($text);

$pdf->WriteHTML($text);

//documentation for Output method here: http://www.fpdf.org/en/doc/output.htm

$attach_pdf_multipart = chunk_split( base64_encode( $pdf->Output( '', 'S' ) ) );

//define the receiver of the email

$to = 'monirulmask@gmail.com';

//define the subject of the email

$subject = 'Test Invoice';

//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: webmaster@test.ch\r\nReply-To: webmaster@test.ch";

//add boundary string and mime type specification

$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";

$msg .= "Content-Type: application/octet-stream; name=\"attachment.pdf\"\r\n";

$msg .= "Content-Transfer-Encoding: base64\r\n";

$msg .= "Content-Disposition: attachment\r\n";

$msg .= $attach_pdf_multipart . "\r\n";

$msg .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n";

$msg .= "Content-Transfer-Encoding: 7bit\r\n\r\n";

$msg .= "

This is text message from shohag

\r\n\r\n";

global $message;

$message = '';

$mail_sent = @mail( $to, $subject, $msg, $headers );

//@mail( $to1, $subject, $msg, $headers );

if(!empty($mail_sent)):

$message = "Invoice sent succuessfully";

else:

$message = "Error occured. Please try again.";

endif;

}

}

请检查我的代码,让我知道更多的可能性.提前致谢.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值