Forum Moderators: coopster
Now, I've gotten it to do everything I want in many ways, but every time I try to open the PDF file, it says it's corrupted, probably due to improper decoding.
Here's what I have set for the mail part of the thing:
require_once($_SERVER['DOCUMENT_ROOT'].'/config.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/lib/MailClass.inc');
$mail = new FreakMailer();
$mail->IsSMTP();
$mail->From = "info@website.com";
$mail->FromName = "Company Name";
$mail->AddAddress($email,$name);
$mail->AddBCC("info@website.com","Company Name");
$mail->AddReplyTo("info@website2.com","Company Name");
$mail->ContentType = "text/plain; charset=iso-8859-15";
$mail->Subject = "$subject";
$mail->Body = "$body";
$mail->AddStringAttachment($string,"filename.pdf");
$mail->Encoding = "base64";
$mail->Type = "application/pdf";
if(!$mail->Send()) {
echo "Message was not sent <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
Does the "filename.pdf" have to be the actual filename on the server? It's a nasty long name, and I thought I could "pretty it up" by calling it something else. But other than that, I don't know why it's coming in corrupted.
By the way, it's on a Windows server.
Any help would be appreciated.
No, it does not have to be the filename as it exists on the server. You are reading the file in to a string variable anyway so you can give it whichever filename you choose. I would check the mail headers to see where the issue lies. Or try reading in and sending a simple text file attachment first to make sure you have everything coming in correctly. Then move on to the PDF attachment.