Has anyone on here managed to get PEAR class Mail_Mime() to send an email along with the files using addAttachment(), with this code block I can send the email, but I don’t see the attached files, like you usually would with the paper clip…and I don’t get any errors when run…I am using Gmail as mail server…
any help would be great… cheers
<?php
require_once("G:/xampplite/php/PEAR/Mail-1.2.0/Mail/mail.php");
require_once("G:/xampplite/php/PEAR/Mail_Mime-1.8.2/Mail_Mime-1.8.2/mime.php");
function check_file($fp/*file path*/)
{
if(file_exists($fp))
{
if(filetype($fp)=="file")
{
return array( basename($fp),
mime_content_type($fp),
filesize($fp));
exit;
}
else
{
return "not a file!!!";
}
}
else
{
return "file don't exist!!!";
exit;
}
}
echo "<pre>";
$smtp = array( 'host'=>"smtp.gmail.com",
'port'=>587,'auth'=>true,
'username'=>"yourusername@gmail.com",
'password'=>"yourpassword",
'localhost'=>"localhost",
'timeout'=>NULL,
'verp'=>FALSE,
'debug'=>FALSE,
'persist'=>TRUE,
'pipelining'=>FALSE);
$from = "yourusername@gmail.com";
$to = "someone@yahoo.com";
$subject = "applying forHigh Reach Forklift / Storeperson position";
$headers = array('From'=>$from,'To'=>$to,'Subject'=>$subject);
$text = "Hello Konstance Tsantis - HR / OHS Advisor
I am applying for the Casual Experienced Forklift Drivers position, with W F Montague P/L ,as advertised online at seek.com.au on 25/Nov/2011
I have attached my resume and cover letter
Thank you for your consideration.
Lee Harvey";
$mailObject =& Mail::factory("smtp",$smtp);
$file_name = "G:/xampplite/htdocs/PDF_Libary/Coverletter_Generator/Warehousing_coverletters/Gen_LHCL.pdf";
$filetype = check_file($file_name);
$file_type = $filetype[1];
$mime = new Mail_Mime();
$mime->setTXTBody($text);
$body = $mime->get();
$headers = $mime->headers($headers);
$mime->addAttachment($file_name,$file_type);
$mailObject->send($to,$headers,$body);
print_r($mailObject);
print_r($mime);
?>