Hi Sophistry and all of viewers,
I’m new on CI community forum (but many times I work with CI). I’m french, so apologize for my scholar english. I hope you understand me.
I find your Imap librairy, it’s amazing, very complete and it helps me a lot. For a personnal project, I have to work on similar functionnality and yesterday when I found your Peeker… you saved my day !
Actually, I succeed to read mail, headers… but, I can’t save the attachement file.
I have an error.
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: filename
Filename: libraries/peeker_parts.php
Line Number: 486
Here is my code (very similar with the Mody code, for example ^^)
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Webmail extends CI_Controller
{
public function __construct()
{
parent::__construct();
// this shows basic IMAP, no TLS required
$config['login']='test@mydomain.com';
$config['pass']='testtest';
$config['host']='xxx.xxx.xxx.xxx';
$config['port']='143';
$config['service_flags'] = '/imap/notls';
$this->load->library('peeker', $config);
$this->peeker->set_attachment_dir(APPPATH."attachments/");
}
public function index()
{
//echo APPPATH.'attachments';
var_dump($this->peeker->get_attachment_dir());
if ($this->peeker->message_waiting())
{
$nbr = $this->peeker->get_message_count();
echo "available: " ,$nbr, "<br />";
for($i = 1; $i <= $this->peeker->get_message_count(); $i++)
{
$email = $this->peeker->get_message($i);
echo $email->Msgno ,"<br />";
echo $email->date ,"<br />";
echo $email->subject ,"<br />";
echo $email->toaddress ,"<br />";
echo $email->fromaddress ,"<br />";
echo $email->from[0]->mailbox,"@",$email->from[0]->host , "<br />";
echo $email->get_plain() , "<br />";
//print_r($email->get_parts_array());
if($email->has_attachment() )
{
//$email->save_all_attachments();
echo "Has attachement<br />";
$email->save_all_attachments();
}
else
{
echo "No attachement<br />";
}
echo "<hr>";
}
}
}
}
/* End of file webmail.php */
/* Location: ./application/controllers/webmail.php */
This var_dump($this->peeker->get_attachment_dir()); return “bool(false)”
So, I think there is a problem with the set_attachment_dir.
I create a folder in APPPATH (/application/attachment) and I set permission to 777
Anyone can helps me ?
Thank you =)