Jump to content

Email attachment help


tobeyt23

Recommended Posts

Trying to attach a dynamically generated pdf as an attachement however it wont attach to the email. The URL for the attachment pulls data from the database and creates the PDF. Here is my code any suggestions:

[code]
<?php
require_once 'phpmailer/class.phpmailer.php';

$mail = new phpmailer();

$yourEmail = '[email protected]';
$yourName = 'Name';

$recipientEmail = '[email protected]';
$recipientName = 'Name';

$mail->From = $yourEmail;
$mail->FromName = $yourName;

$mail->Subject = 'Test Attachment';

$body = 'This message has an attachment';
$mail->Body = $body;

if (!$mail->AddAttachment('../sample.php?Product=24&Data=1', 'sample.pdf, 'base64', 'application/pdf')) {
echo 'Failed to attach file!<br />';
}

$mail->AddAddress($recipientEmail, $recipientName);

if (!$mail->Send()) {
echo 'Mail sending failed';
} else {
echo ' Mail sent successfully';
}
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/27978-email-attachment-help/
Share on other sites

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.