I'm using Mailgun to receive emails for my web app developed using Codeigniter. Mailgun makes a http post to the following (http://something.com/email) url for every incoming email.
I get the contents of the email with the following code.
function email_to_db(){
$email_body = $this->input->post('body-plain', '');
$email_sender = $this->input->post('sender');
}
However I'm not able to fetch the attachments.
Can someone guide me on how I can achieve this. Following is the link to my reference doc.
attachments are files, you should use File Uploading Class
$config = [];
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 100;
$config['max_width'] = 1024;
$config['max_height'] = 768;
$this->load->library('upload', $config);
if (!$this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
}
else
{
$data = array('upload_data' => $this->upload->data());
}
you can also do print_r($_FILES);
and check the attachment files.