i am using mime smtp yo send mail . my problem is mail is going without any attachment . i want to send pdf mail with attachment. my code is as follows
$a = $fpdf->writeHTML($fpdf, true, false, true, false, '') ;
//$a = $fpdf->Output() ;
$host = 'smtp.ample.co.in';
$username = 'nasadnivas@aadsmple.co.in';
$password = 'asa3';
$to = "namadsivas@ampxle.co.in";
$from = "nadnivas@amsple.co.in";
$subject = "Attachments Test";
$filename = "test";
$headers = array(
'To' => $to,
'From' => $from,
'Subject' => $subject
);
$smtp = Mail::factory('smtp', array('host'=>$host, 'auth'=>true, 'username'=>$username, 'password'=>$password));
$text = "Plain Text Email Content";
$html = "HTML Email Content
";
//$attachment = "mail_serinv.php?tchyear=2014&tchfyear=14&tchcid=001&tninvid=105466&tcpflag=I&tcnflag=L";
$mime = new Mail_mime();
$mime -> setTXTBody($text);
$mime -> setHTMLBody($html);
$mime -> addAttachment($a, 'text/plain',$filename,false);
$body = $mime -> get();
$headers = $mime -> headers($headers);
$mail = $smtp -> send($to, $headers, $body);
if(PEAR::isError($mail)) {
echo $mail->getMessage();
} else {
echo 'Message sent';
}
i search many links and found useless . please help me in finding the solution
Try this :
Saving the PDF file to server (make sure you have 777 writing permissions for that folder!): - See more at: http://blog.startq.com/2011/10/25/fpdf-output-methods-for-pdf-files-in-php/#sthash.J5K9EQ4h.dpuf
$a = $fpdf->Output('directory/yourfilename.pdf','F');
...
$mime -> addAttachment($a, 'application/pdf',$filename,true);