salve!
ho integrato TCPDF in codeigniter, e risco a creare i file pdf.
solo che vorrei che il file fosse direttamente allegato alla email.
nel controller ho fatto così:
questo invece la classe che invia l'email:Codice PHP:$titolo = 'Prova';
$pdf = new Pdf(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetTitle($titolo);
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, $titolo);
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->SetFont('dejavusans', '', 10);
$pdf->AddPage();
$pdf->Write(5, 'Ciao');
$pdf->lastPage();
$attach = $pdf->Output($titolo . '.pdf', 'E');
$messaggio = 'Ciao';
$this->email_model->sendEmail(email, Prova, $messaggio, chunk_split($attach));
se non metto l'allegato l'email arriva con il testo.Codice PHP:<?php
class Email_model extends CI_Model {
public function sendEmail($to, $subject, $message, $attach = NULL) {
$this->load->library('email');
$this->email->initialize(array(
'mailtype' => 'html',
'charset' => 'utf-8'
));
$this->email->from(email, DA ME);
$this->email->to($to);
$this->email->subject($subject);
$this->email->message($message);
$this->email->attach($attach);
$this->email->send();
}
}
se invece gli passo l'allegato l'email arriva, ma senza ne testo ne allegato.
secondo voi è possibile fare quello che sto cercando di fare?

Rispondi quotando