07-03-2007, 05:00 PM
[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:
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?
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();
}
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?