Welcome Guest, Not a member yet? Register   Sign In
send 3 email each with attachment
#1

Hi , sorry for english , i create a function :
PHP Code:
    public function send_email($email$subject,$messaggio_formattato,$attachment=null)
    {
        
        $this
->load->library('email');
        $this->config->load('email_config');


        $this->email->set_mailtype("html");

        $this->email->from($this->config->item('email_sito'), $this->config->item('email_sito_name'));
        $this->email->to($email);


        $this->email->subject($subject);

        $message '
        <html>
        <head>
            <title></title>
        </head>
        <body>'
.
        $messaggio_formattato
        
.

        '
        </body>
        </html>'
;

        $this->email->message($message);

        //se c'è l'allegato lo aggiungo
        if ($attachment) {
  
          $this
->email->attach($attachment);
          
        
}

        return $this->email->send();

    

in a controller function i create a pdf with fpdf and save a temporany file :

$pdf_filename = "order_".$res_order.".pdf";

$pdf->Output($pdf_filename, "F");

Than i send 3 email .

$this->send_email($this->config->item('email_admin'), $subject,$messaggio_formattato,$pdf_filename);


$this->send_email($agente->email, lang('ordini_ordini_inviato'), lang('ordini_ordini_inviato_messaggio') ,$pdf_filename);


$this->send_email($user->email, lang('ordini_ordini_inviato'), lang('ordini_ordini_inviato_messaggio_user') ,$pdf_filename);


In first email i have an attachment , in second two attachment in third 3 attachment.....Why ?
Reply
#2

(This post was last modified: 11-06-2019, 05:45 PM by dave friend.)

Probably because send() clears all the properties unless you tell it not to. Change the last line to

PHP Code:
return $this->email->send(false); 
Reply
#3

(This post was last modified: 11-07-2019, 05:08 AM by pippuccio76.)

(11-06-2019, 05:44 PM)dave friend Wrote: Probably because send() clears all the properties unless you tell it not to. Change the last line to

PHP Code:
return $this->email->send(false); 

Same error , 1  2 and 3 attachment with false too.

(11-07-2019, 04:57 AM)pippuccio76 Wrote:
(11-06-2019, 05:44 PM)dave friend Wrote: Probably because send() clears all the properties unless you tell it not to. Change the last line to

PHP Code:
return $this->email->send(false); 

Same error , 1  2 and 3 attachment with false too.

Now work ... in the function send_email under  load library i insert this :

$this->email->clear(TRUE);
Reply




Theme © iAndrew 2016 - Forum software by © MyBB