• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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
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
(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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.