Farzher
Farzher

Reputation: 14573

PHPMailer AddAttachment remote file

$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.

Upvotes: 2

Views: 6906

Answers (1)

Harry B
Harry B

Reputation: 2972

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

Upvotes: 8

Related Questions