Solved

Sending PDF attachments using PHPMailer

Posted on 2008-10-15
2
4,192 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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 …

739 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