MrGeeezer
asked on
PHP/Pear Mail script not sending attachments
Hi,
I am writing a php application, and one part of the requirement is to mail a pdf file to someone.
I downloaded a script to use as my mail server needs smtp authentication etc.
Whilst the script DOES generate an email as expected, the actual email has loads of random rubbish in the body.
I changed the mime type to application/pdf but still I get loads of rubbish and no actual attachment.
I have shown the code from my script - can someone please fix it for me?
Thanks.
I am writing a php application, and one part of the requirement is to mail a pdf file to someone.
I downloaded a script to use as my mail server needs smtp authentication etc.
Whilst the script DOES generate an email as expected, the actual email has loads of random rubbish in the body.
I changed the mime type to application/pdf but still I get loads of rubbish and no actual attachment.
I have shown the code from my script - can someone please fix it for me?
Thanks.
include('Mail.php');
include('Mail/mime.php');
$text = 'Text version of email';
$html = '<html><body>HTML version of email</body></html>';
$file = './quote.pdf';
$crlf = "rn";
$hdrs = array(
'From' => 'xxx@xxx.co.uk',
'To' => 'xxx.xxx@xxx.com',
'Subject' => 'Your Quotation'
);
$params = array(
'host' => "ssl://mail.xxx.co.uk",
'port' => "465",
'username' => "xxx",
'password' => "xxx"
);
$mime = new Mail_mime($crlf);
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
$mime->addAttachment($file,'application/pdf');
$body = $mime->get();
$hdrs = $mime->headers($hdrs);
$mail =& Mail::factory('smtp', $params);
$mail->send('xxx@xxx.com', $hdrs, $body);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER