Posts: 16
Threads: 3
Joined: Jan 2016
Reputation:
0
Hi all, currently really stumped.... For some reason no matter what I try I cannot get this attachment loaded on to an email to send. If I pass in a bad path the email will send without the attachment but if I pass in the correct url the email just doesn't send and I don't get anything printed out either when i try the print_debugger.
Here is a code_snippet of what I'm doing
Code: log_message('debug', 'screening is not blank');
// Get custom email content
$this->_ci->load->model('contents_model');
//$this->_ci->contents_model->initialize();
$this->_ci->contents_model->slug = 'screening-certificate-email';
$user_data['custom_content'] = $this->_ci->contents_model->load(true);
// send feedback PDF
$file_path = CERTIFICATE_FILE_PATH . '/' . $screening->slug . '.pdf';
$this->_ci->load->library('email');
$this->_ci->email->from('xxxxxxxxxxx');
$this->_ci->email->to($email);
$this->_ci->email->subject('Your Requested Certificate from ' . SITE_NAME);
$this->_ci->email->message($this->_ci->load->view('public/email/certificate', $user_data, TRUE));
log_message('debug', $_SERVER['DOCUMENT_ROOT']);
$this->_ci->email->attach($file_path);
log_message('debug' , $this->_ci->email->print_debugger());
log_message('debug', $file_path);
The file_path equates to /var/downloads/certificates/xxxx.pdf
Any thoughts or help would be much appreciated thank you!
Posts: 1,298
Threads: 62
Joined: Oct 2014
Reputation:
86
(02-10-2016, 11:27 PM)acheng16 Wrote: Hi all, currently really stumped.... For some reason no matter what I try I cannot get this attachment loaded on to an email to send. If I pass in a bad path the email will send without the attachment but if I pass in the correct url the email just doesn't send and I don't get anything printed out either when i try the print_debugger.
Here is a code_snippet of what I'm doing
Code: log_message('debug', 'screening is not blank');
// Get custom email content
$this->_ci->load->model('contents_model');
//$this->_ci->contents_model->initialize();
$this->_ci->contents_model->slug = 'screening-certificate-email';
$user_data['custom_content'] = $this->_ci->contents_model->load(true);
// send feedback PDF
$file_path = CERTIFICATE_FILE_PATH . '/' . $screening->slug . '.pdf';
$this->_ci->load->library('email');
$this->_ci->email->from('xxxxxxxxxxx');
$this->_ci->email->to($email);
$this->_ci->email->subject('Your Requested Certificate from ' . SITE_NAME);
$this->_ci->email->message($this->_ci->load->view('public/email/certificate', $user_data, TRUE));
log_message('debug', $_SERVER['DOCUMENT_ROOT']);
$this->_ci->email->attach($file_path);
log_message('debug' , $this->_ci->email->print_debugger());
log_message('debug', $file_path);
The file_path equates to /var/downloads/certificates/xxxx.pdf
Any thoughts or help would be much appreciated thank you!
I believe the output of print_debugger is an array, and cannot be sent to log unless converted to string, so you might try to json_encode it.
Posts: 16
Threads: 3
Joined: Jan 2016
Reputation:
0
(02-11-2016, 12:14 AM)skunkbad Wrote: (02-10-2016, 11:27 PM)acheng16 Wrote: Hi all, currently really stumped.... For some reason no matter what I try I cannot get this attachment loaded on to an email to send. If I pass in a bad path the email will send without the attachment but if I pass in the correct url the email just doesn't send and I don't get anything printed out either when i try the print_debugger.
Here is a code_snippet of what I'm doing
Code: log_message('debug', 'screening is not blank');
// Get custom email content
$this->_ci->load->model('contents_model');
//$this->_ci->contents_model->initialize();
$this->_ci->contents_model->slug = 'screening-certificate-email';
$user_data['custom_content'] = $this->_ci->contents_model->load(true);
// send feedback PDF
$file_path = CERTIFICATE_FILE_PATH . '/' . $screening->slug . '.pdf';
$this->_ci->load->library('email');
$this->_ci->email->from('xxxxxxxxxxx');
$this->_ci->email->to($email);
$this->_ci->email->subject('Your Requested Certificate from ' . SITE_NAME);
$this->_ci->email->message($this->_ci->load->view('public/email/certificate', $user_data, TRUE));
log_message('debug', $_SERVER['DOCUMENT_ROOT']);
$this->_ci->email->attach($file_path);
log_message('debug' , $this->_ci->email->print_debugger());
log_message('debug', $file_path);
The file_path equates to /var/downloads/certificates/xxxx.pdf
Any thoughts or help would be much appreciated thank you!
I believe the output of print_debugger is an array, and cannot be sent to log unless converted to string, so you might try to json_encode it. Code: DEBUG - 2016-02-11 09:46:30 --> in send certificate
DEBUG - 2016-02-11 09:46:30 --> email is not blank
DEBUG - 2016-02-11 09:46:30 --> Model Class Initialized
DEBUG - 2016-02-11 09:46:30 --> screening is not blank
DEBUG - 2016-02-11 09:46:30 --> Model Class Initialized
INFO - 2016-02-11 09:46:30 --> Email Class Initialized
DEBUG - 2016-02-11 09:46:30 --> File loaded: application/views/[b]public[/b]/email/inc$
DEBUG - 2016-02-11 09:46:30 --> File loaded: application/views/[b]public[/b]/email/inc$
DEBUG - 2016-02-11 09:46:30 --> File loaded: application/views/[b]public[/b]/email/cer$
DEBUG - 2016-02-11 09:46:30 --> /var/screenu-www/screenu-web
Good point but with that being said if I look in the log it just gets stuck after the email attach?
Posts: 1,298
Threads: 62
Joined: Oct 2014
Reputation:
86
What happens if you use is_file() on $file_path?
What happens if you try to set the attachment immediately after you load the email library?
Posts: 16
Threads: 3
Joined: Jan 2016
Reputation:
0
(02-11-2016, 09:08 AM)skunkbad Wrote: What happens if you use is_file() on $file_path?
What happens if you try to set the attachment immediately after you load the email library?
It is a file when I called the is_file and when I directly visit the equivalent URL on my website.
If I try to load it after the email library. Once the attach is called nothing else after runs...
Posts: 1,298
Threads: 62
Joined: Oct 2014
Reputation:
86
02-11-2016, 01:30 PM
(This post was last modified: 02-11-2016, 01:34 PM by skunkbad.)
I will be mocked if I tell you to replace all files in your /system directory with fresh copies, so instead I'll just tell you that I have no clue what's going on. I've used the email library extensively, including attachments, and never heard or seen anything like this.
I think you should make a test controller, with a minimal usage of email with attachment, and see what happens. If that works then it's for sure something about your code.
Posts: 16
Threads: 3
Joined: Jan 2016
Reputation:
0
(02-11-2016, 01:30 PM)skunkbad Wrote: I will be mocked if I tell you to replace all files in your /system directory with fresh copies, so instead I'll just tell you that I have no clue what's going on. I've used the email library extensively, including attachments, and never heard or seen anything like this.
I think you should make a test controller, with a minimal usage of email with attachment, and see what happens. If that works then it's for sure something about your code.
Lol I am literally laughing my butt of typing this but I actually inherited this project from a previous developer and lets just say he was not the brightest one.... I replaced the Email.php file in the system library and started working so thank you for the idea!
Posts: 1,298
Threads: 62
Joined: Oct 2014
Reputation:
86
(02-11-2016, 02:36 PM)acheng16 Wrote: (02-11-2016, 01:30 PM)skunkbad Wrote: I will be mocked if I tell you to replace all files in your /system directory with fresh copies, so instead I'll just tell you that I have no clue what's going on. I've used the email library extensively, including attachments, and never heard or seen anything like this.
I think you should make a test controller, with a minimal usage of email with attachment, and see what happens. If that works then it's for sure something about your code.
Lol I am literally laughing my butt of typing this but I actually inherited this project from a previous developer and lets just say he was not the brightest one.... I replaced the Email.php file in the system library and started working so thank you for the idea!
Oh, the satisfaction of being right. Glad it worked.
|