php - PHPMailer can't attach a pdf file -
i've been trying send email pdf attachment in it. i'm using phpmailer can't seem manage it. i've been trying tons of different addattachment methods , tried different file paths. here code:
require_once ("class.phpmailer.php"); $lc_name = $_session['lc_name']; $filename = "email_attachment/".$lc_id.".pdf"; require_once ("func_ui.php"); $vou_mail = func_ui::select_mail($lc_id, 3); if($vou_mail["auto"] == 0) { return; } else { $custom_body = $vou_mail["body"]; } $body = "dear customer,<br><br> $custom_body<br><br> kind regards,<br><br> $gm_name<br> centre manager"; $mail = new phpmailer(); seek { $mail->issmtp(); $mail->host = "****"; // smtp server $mail->smtpauth = true; // enable smtp authentication // $mail->smtpsecure = "ssl"; // sets prefix servier $mail->port = ***; // set smtp port gmail server $mail->username = "******"; // gmail username $mail->password = "****"; // gmail password $from_name = '***'; $subject = ''; //$mail->addattachment($filename, "", "base64", "application/pdf"); //$mail->addattachment(realpath('./email_attachment/1220.pdf'),'1220.pdf','base64', 'application/pdf'); $mail->setfrom('info@***.com', ""); $mail->addreplyto("info@***.com", ""); $mail->subject = "$lc_name - voucher."; //$mail->ishtml(false); $reason = $mail->addattachment("/email_attachment/1220.pdf"); $mail->altbody = "to view message, please utilize html compatible m_email viewer!"; // optional, comment out , test $mail->msghtml($body); $mail->addaddress($email_v, ""); if ($reason == false){ echo "didn't line\n"; } else { echo "worked ?"; } if(! $mail->send()) { echo "mailer error: " . $mail->errorinfo; } else { echo "message sent!"; } $mailer->clearaddresses(); $mailer->clearattachments(); } grab (phpmailerexception $e) { echo $e->errormessage(); //pretty error messages phpmailer } grab (exception $e) { echo $e->getmessage(); //boring error messages else! } php email attachment phpmailer
No comments:
Post a Comment