PHPMailer AddAttachment remote file
Asked Answered
E

1

2
$remote_path = 'http://bucket.s3.amazonaws.com/whatever.txt';
$mail->AddAttachment($remote_path);

This doesn't work because PHPMailer wants a local file, or binary data. It tried this too:

$data = file_get_contents($remote_path);
$mail->AddAttachment($data);

I don't want to download it into a local file if I don't have to. Why doesn't the file_get_contents version work? Is it a string and not binary data?

Edit: I get no errors.

Erbium answered 10/5, 2013 at 15:27 Comment(0)
C
8

You should take a look at an alternative phpmailer function called AddStringAttachment:

AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream')

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

Consumerism answered 19/5, 2013 at 22:0 Comment(1)
and you must set: $string = file_get_contents("mywebsite/report/…);Vance

© 2022 - 2024 — McMap. All rights reserved.