2016-06-02 37 views
0

PHPMailerクラスを使用したattachment.iで電子メールを送信する関数を作成しました。 電子メールは送信されますが、添付ファイルが取得されません。無意味な流暢なインターフェイスの報酬を収獲私の電子メールにPdfが添付されていません

私のコントローラコード

public function send_mail() 
     { 
     $this->load->library('email'); 

      $subject = 'Request For Quotation'; 
      $message = '<p>This message has been sent for testing purposes.</p>'; 

      // Get full html: 
      $body = 
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset='.strtolower(config_item('charset')).'" /> 
    <title>'.html_escape($subject).'</title> 
    <style type="text/css"> 
     body { 
      font-family: Arial, Verdana, Helvetica, sans-serif; 
      font-size: 16px; 
     } 
    </style> 
</head> 
<body> 
'.$message.' 
</body> 
//</html>'; 
      $this->load->library('M_pdf'); 
    $this->m_pdf->pdf->setTitle('Request for Quotation'); 
    $html = 'hiiiiiiiiiiiiiiiiiiiiiiiiiiiiii'; 
    $this->m_pdf->pdf->WriteHTML($html); 
    $content=$this->m_pdf->pdf->Output('RFQ.pdf',"S"); 
    $result = $this->email->from('[email protected]')->to('[email protected]')->subject($subject)->message($body)->attach($content, '', 'base64', '')->send(); 
    var_dump($result); // echo '<br />'; echo $this->email->print_debugger(); exit; 
    } 
+0

。例外処理を追加したり、戻り値をチェックしたりしてください。 – Synchro

+0

私を助けることができます、私はたくさん試しましたが、得られません。 – user6413618

+0

あなたは[codeigniter docs](http://www.codeigniter.com/user_guide/libraries/email.html)を読む必要があります。 – Synchro

答えて

0
use this code.............. 
    $pdfFilePath = "PDF/RFQ.pdf"; 
    $html='hiiiiiiiiiiiiiii'; 
    //load mPDF library 
    $this->load->library('m_pdf'); 
    //generate the PDF from the given html 
    $this->m_pdf->pdf->WriteHTML($html); 
    //download it. 
    ob_clean(); 
    $this->m_pdf->pdf->Output($pdfFilePath,'F'); 


    $config = Array(
     'protocol' => 'smtp', 
     'smtp_host' => 'ssl://smtp.googlemail.com', 
     'smtp_port' => 465, 
     'smtp_user' => 'Email', 
     'smtp_pass' => 'Password', 
     'mailtype' => 'html', 
     'charset' => 'iso-8859-1', 
     'wordwrap' => TRUE 
    ); 
     $this->load->helper('path'); 
     $this->load->library('email', $config); 
     $this->email->set_newline("\r\n"); 
     $this->email->from('Email'); 
     $this->email->to('email'); 
     $this->email->subject('Subject'); 
     $this->email->attach($pdfFilePath); 
     $this->email->send(); 
関連する問題