Solved

Sending PDF attachments using PHPMailer

Posted on 2008-10-15
2
3,917 Views
Last Modified: 2012-05-05
Hi,

Am sending a PDF attachment using PHPMailer like this:

$mail->AddStringAttachment("files/pdf/name.pdf", "name.pdf");

The attachment is sent with the email, but when I try to open, or save it to my machine to open it, get a message saying "couldnt opne file because it's either not a supported file type or because the file has been damaged eg it was sent as an attachment and wasnt correctly encoded....

I tried adjust the method above like this:

$mail->AddStringAttachment("files/pdf/name.pdf", "name.pdf","base64", "application/pdf")

but this didnt work.

The original file (I am sending) does open ok.

Any thoughts greatly appreciated.

Daisy
 
0
Comment
Question by:daisydoos
2 Comments
 
LVL 19

Accepted Solution

by:
BrianGEFF719 earned 125 total points
ID: 22728499
Try:

$mail->AddAttachment(realpath('./files/pdf/name.pdf'),'name.pdf','base64', 'application/pdf');

or:

$mail->AddAttachment(realpath('files/pdf/name.pdf'),'name.pdf','base64', 'application/pdf');
0
 

Author Comment

by:daisydoos
ID: 22728656
Hi Brian,

many thanks - worked a treat!

Cheers,

Daisy
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question