Jump to content

Simple Email - How do you attach a PDF?


webmaster1

Recommended Posts

Hi All,

 

I have a simple email process in form I've built:

 

<?php
$to = "$recipientemail";
$subject = "New message: $Howdy...";
$message = "Hi $recipientname,\n\n Further to our recent telephone conversation please find attached additional information
            regarding our package pricing.\n\nWe look foward to your response.\n\nKind Regards,\n$salesagentname";
$headers = "From: [email protected]";

// SEND THE EMAIL USING PHPs mail() function
mail($to, $subject, $message, $headers);

?>

 

I was hoping someone could point me in the direction of a few code economic tutorials. Everything I've searched so far is very longwinded.  Is this the only way?

 

(I searched Google under 'php attach pdf')

Link to comment
https://forums.phpfreaks.com/topic/140352-simple-email-how-do-you-attach-a-pdf/
Share on other sites

have a look at this pear package something like this should do it

http://pear.php.net/package/Mail_Mime

$mime = new Mail_mime();
$to = "$recipientemail";
$subject = "New message: $Howdy...";
$mime->encodeRecipients($to);
$mime->setSubject("New message: $Howdy...");
$mime->setTXTBody($message);
$mime->addAttachment("file.pdf","application/pdf");
$mime->setFrom("[email protected]");
mail($to,$subject,$mime->getMessage());

 

Scott.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.