• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
email->attach() attaching file twice

#1
[eluser]ImageSmith[/eluser]
Well this is a bit of a doozie. I'm sure it is a simple fix but I'm not seeing it right now :ohh:
I am generating 2 emails as a result of a form submission (validated, etc). One email to the client, one to the site owner / organisation. I have a function for each email type (client, org).
The form result has been written into a PDF using FPDF.
The pdf is attached to both emails. However (this is the odd thing), the pdf is attaching to the org email twice :-S .
I have called the clear method in each function, but the issue persists.
Here are the mail functions:
Code:
function _generate_client_email($message_view,$subject,$attachment = '')
{
  if (!$this->allow_email_send) { // set in config file
    return;
  }
  $ci =& get_instance();
  $ci->load->library('email');
  
  $config['mailtype'] = 'html';
  $ci->email->clear();
  $ci->email->initialize($config);
  
  $ci->email->to($ci->validation->email);
  $ci->email->from($ci->config->item('enquiry_form_recipient'));
  $ci->email->subject($subject);
  $ci->email->message($ci->load->view($message_view,'',true));
  $ci->email->set_alt_message($ci->load->view($message_view.'_plain','',true));
  if ($attachment) {
    $ci->email->attach($attachment);
  }
  $ci->email->send();
}

function _generate_org_email($message_view,$subject = 'Website Email',$params = '',$attachment = '')
{
  if (!$this->allow_email_send) { // set in config file
    return;
  }
  $ci =& get_instance();
  $ci->load->library('email');
  
  $params['from_name'] = $params['from_name'] ? $params['from_name'] : $ci->validation->first_name.' '.$ci->validation->last_name;
  
  $config['mailtype'] = 'html';
  $ci->email->clear();
  $ci->email->initialize($config);
  
  $ci->email->from($ci->validation->email,$params['from_name']);
  $ci->email->to($ci->config->item('enquiry_form_recipient'));
  $ci->email->subject($subject);
  $ci->email->message($ci->load->view($message_view,$params,true));
  $ci->email->set_alt_message($ci->load->view($message_view.'_plain','',true));

  if ($attachment) {
    $ci->email->attach($attachment);
  }
  $ci->email->send();
}
The client function is called first.

EDIT - if I call the org function first then I get 2 attachments in the client email.
Is there something that I should be clearing further here?


Messages In This Thread
email->attach() attaching file twice - by El Forum - 07-03-2007, 05:00 PM
email->attach() attaching file twice - by El Forum - 07-04-2007, 09:12 AM
email->attach() attaching file twice - by El Forum - 07-04-2007, 10:54 PM
email->attach() attaching file twice - by El Forum - 07-05-2007, 03:59 AM
email->attach() attaching file twice - by El Forum - 07-05-2007, 04:03 PM
email->attach() attaching file twice - by El Forum - 07-31-2008, 04:01 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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