$remote_path = 'http://bucket.s3.amazonaws.com/whatever.txt';
$mail->AddAttachment($remote_path);
这不起作用,因为PHPMailer需要本地文件或二进制数据。它也尝试了这个:
$data = file_get_contents($remote_path);
$mail->AddAttachment($data);
如果我不需要,我不想将其下载到本地文件中。为什么file_get_contents
版本不起作用?它是字符串而不是二进制数据吗?
编辑:我没有错误。
答案 0 :(得分:7)
你应该看一个名为AddStringAttachment的替代phpmailer函数:
AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream')