PHPMailer附件,没有物理文件

Kar*_*rem 15 php phpmailer

所以:

// Setup mail class, recipients and body
$mailer->AddAttachment('/home/mywebsite/public_html/file.zip', 'file.zip');
The AddAttachment function has four arguments:

AddAttachment(PATH_TO_FILE, FILENAME, ENCODING, HEADER_TYPE)
Run Code Online (Sandbox Code Playgroud)

我以前使用xmail(),当我在这里添加附件时,我传递了文件名和内容,应该在其中.

像这样:

$xmail->addAttachment('myamazingfile.pdf', $content);
Run Code Online (Sandbox Code Playgroud)

我怎么能以同样的方式工作,所以当我AddAttachment()从PHPmailer类调用时,我可以传递相同或类似的东西,所以我不需要在我的服务器上有一个实际的文件发送?

goa*_*oat 37

AddStringAttachment($string,$filename,$encoding,$type)
Run Code Online (Sandbox Code Playgroud)

例如

$mail = new PHPMailer();
$mail->AddStringAttachment($string,$filename,$encoding,$type);
Run Code Online (Sandbox Code Playgroud)

http://phpmailer.worxware.com/index.php?pg=tutorial#3

  • 对于尝试此操作的任何人,编码可能是“base64”,而 $type 是 MIME 类型的字符串。 (2认同)