gpt4 book ai didi

PHPmailer 和 pdf 附件

转载 作者:可可西里 更新时间:2023-11-01 13:42:58 26 4
gpt4 key购买 nike

我正在尝试使用 phpmailer 类发送带有 PDF 附件的电子邮件。

我使用了这段代码:

mailTo 函数中:

$mail->AddAttachment($pdffile);

其中 $pdffile = $_SERVER['DOCUMENT_ROOT'] 。 “/facturen/test.pdf”

发送邮件会产生一封没有附件但包含以下内容的电子邮件:

--b1_3768f40f33d9a5dec555d03a15af14f9
Content-Type: text/html; charset = "iso-8859-1"
Content-Transfer-Encoding: 8bit

在我的电子邮件顶部和底部:

--b1_3768f40f33d9a5dec555d03a15af14f9 
Content-Type: application/octet-stream; name="test.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test.pdf"

JVBERi0xLjQKJcfsj6IKMTEgMCBvYmoKPDwvTGVuZ3RoIDEyIDAgUi9GaWx0ZXIgL0ZsYXRlRGVj
b2RlPj4Kc3RyZWFtCnic7VtZs9zEFa5A2CYpQyALSUiiNyQqI3pfeGOrOECgMJc8BPJg38Xbta8x
NqbyL/Jn85yvF6mPpNbMXMoPVCrlskvT6j59+izfWdT+pmG9UA0Lf4aH43ubt69x2dz8dsOb8Ofh
zY2zrGfeNU7yXmvf3Ns4wXrDxDhiHes50431vGdGlt8K741pjjfDiMEMbZuBgNHhp2qGLYbfxxvP
fa+9Gke8CTOG9flXoT8MZAaG1QOD8yMcb87e2sieCwXST3DUj/D3Tj7ytb/8bx751uaLzTcNV1r3
0kVtcy5Vr3ijmeqNwFzfc+51tgLVfHCx+XwT7SMIRbMgsUAZkzkPlFygBCq2V83D00jfOZAUJtE3
eHamwSoBJhvJlOidzfR1or97iXAWm/i8xBy0xHLZDytsfYXoPV2hNes9z0tcWgKxKq5NMA8RVJCn
QVzO6UjKaJxb6XTyJCa4yzcb1XNjjI

等等……

如何解决?

最佳答案

试试这个,它对我有用......

   $mail->AddAttachment('path_to_pdf', $name = 'Name_for_pdf',  $encoding = 'base64', $type = 'application/pdf');

在你的情况下

    $mail->AddAttachment($_SERVER['DOCUMENT_ROOT'].'/facturen/test.pdf', $name = 'test',  $encoding = 'base64', $type = 'application/pdf');

关于PHPmailer 和 pdf 附件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19072038/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com