Solved

Sending PDF attachments using PHPMailer

Posted on 2008-10-15
2
3,733 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

744 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now