Part of the EllisLab Network
This thread is a discussion for the wiki article: peeker
   
6 of 7
6
peeker
Posted: 10 February 2012 09:18 PM   [ Ignore ]   [ # 76 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1101
Joined  08-06-2006

great work! a verified bug - and a pretty tricky one too.

here’s how to fix it if you don’t want to wait for me to update github:

change the get_message() method in peeker.php to this:
(basically adding the unset() line)

public function get_message($start$end=NULL)
 
{
  
// set the message class to the parts class
  // that just gets everything, this disturbs
  // the read state on gmail POP accounts
  //$this->set_message_class('peeker_parts');
  // set up a detector that calls 
  // the email acquistion method
  // remove the detector_set so it is recreated new each time
  // in case get_message is called in a loop and detector 
  // just stacks up get_parts calls
  
unset($this->detector_set);
  
$this->make_detector_set();
  
// the most complete email "pulling" method
  // but, only works with peek_mail_parts class
  
$this->detector_set->detect_phase('get_parts');
  
// run the acquisition loop
  
return $this->message($start$end);

 

let us know how that works for you.

 Signature 

peeker email (imap/pop) | site_migrate | OOCalendar | PhotoBox2 | word_limiter

Profile
 
 
Posted: 10 February 2012 09:48 PM   [ Ignore ]   [ # 77 ]  
Summer Student
Total Posts:  16
Joined  07-09-2011

Thanks, Its now working as expected
one other thing, I’m getting this sometimes

SeverityNotice
Message
Undefined propertypeeker::$detector_set
Filename
libraries/peeker.php
Line Number
753

and

SeverityNotice
Message
Trying to get property of non-object
Filename
libraries/peeker_body.php
Line Number
116 

sometimes

Have a great weekend!

Profile
 
 
Posted: 12 February 2012 11:10 AM   [ Ignore ]   [ # 78 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1101
Joined  08-06-2006

Hi Mody,

Thanks for the follow up.

Those errors are caused because the fetchController index method code asks the mail server for message number 0 (which does not exist).

Mail server MsgNos start at 1. I have added some error log code to the peeker libs to inform developers of this state.

I’ll push to GitHub shortly.

Let me know if you have anything else - appreciate the nice bug reports.

Cheers.

 Signature 

peeker email (imap/pop) | site_migrate | OOCalendar | PhotoBox2 | word_limiter

Profile
 
 
Posted: 08 April 2012 06:36 PM   [ Ignore ]   [ # 79 ]  
Grad Student
Avatar
Rank
Total Posts:  50
Joined  01-13-2010

I’m trying to use this library, but I’m stuck at the very basic stage - I cannot connect.  I have used the examples from the Quickstart exactly as they are with the changes for my email, etc. but I get the following message even when I try to connect to my gmail :

No messages waiting.Array ( [0] => Connection could not be closed. No Mail resource. )

I’m obviously missing something basic - anyone have any ideas?

// gmail IMAP
        
$config['login''myname@gmail.com';
        
$config['pass''mypassword';
        
$config['host''imap.gmail.com';
        
$config['port''993';
        
$config['service_flags''/imap/ssl/novalidate-cert';

        
$this->load->library('peeker'$config);

        if (
$this->peeker->message_waiting()) {
            
echo 'Message count:' $this->peeker->get_message_count();
        
else {
            
echo 'No messages waiting.';
        
}

        $this
->peeker->close();

// tell the story of the connection
        
print_r($this->peeker->trace()); 
Profile
 
 
Posted: 09 April 2012 11:58 PM   [ Ignore ]   [ # 80 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1101
Joined  08-06-2006

the previous poster had some success removing the imap from the service_flags config param. also, make sure you have followed the quickstart documentation that has some hints about making sure your ssl is on in php and that the imap is on for your gmail acct. this thread we are in right now has some good mail debugging advice too.

cheers!

 Signature 

peeker email (imap/pop) | site_migrate | OOCalendar | PhotoBox2 | word_limiter

Profile
 
 
Posted: 11 April 2012 10:47 AM   [ Ignore ]   [ # 81 ]  
Grad Student
Avatar
Rank
Total Posts:  50
Joined  01-13-2010

Thanks sophistry,
I’ve read through everything again and still can’t figure it out.  Perhaps I’m missing something with the php set up.

I’m using PHP Version 5.2.17
under Imap it says :

IMAP c-Client Version 2007f
SSL Support enabled
Kerberos Support enabled

And Gmail says : Status: IMAP is enabled

I know I’m missing something really basic - any help would be greatly appreciated - Thanks.

Profile
 
 
Posted: 11 April 2012 05:43 PM   [ Ignore ]   [ # 82 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1101
Joined  08-06-2006

are you able to connect with the same gmail account on imap by using another imap client on the same machine where you are running peeker code? also, did you try changing the service flags? see imap_open() manual page for variations to try.

 Signature 

peeker email (imap/pop) | site_migrate | OOCalendar | PhotoBox2 | word_limiter

Profile
 
 
Posted: 23 April 2012 09:19 AM   [ Ignore ]   [ # 83 ]  
Summer Student
Total Posts:  7
Joined  08-21-2007

Hi Sophistry,

Thanks for this impressive library !

I’m using peeker for a some personal project, i have read entire documentation and all this thread. I have one question but didn’t find answer from previous help.

Does it possible to retrieve message without attachment, i mean just header and body data ?

$this->peeker->message(); 

This method works fine for header information but don’t have body data

$this->peeker->get_message(); 

This method works fine for body information but with attachment

I hope you understand, sorry for my english.

Thanks again !

Profile
 
 
Posted: 23 April 2012 05:46 PM   [ Ignore ]   [ # 84 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1101
Joined  08-06-2006

yes! that is one of the design goals of this project- modular email fetching.

try set_message_class(‘peeker_body’) and use the direect call to message() method instead of get_message().

then you have to use get_body() to avoid getting the attachments.

see the get_message() method for one way of setting this up using detectors , though it may be too complex to use detectors. 

 Signature 

peeker email (imap/pop) | site_migrate | OOCalendar | PhotoBox2 | word_limiter

Profile
 
 
Posted: 24 April 2012 05:27 AM   [ Ignore ]   [ # 85 ]  
Summer Student
Total Posts:  7
Joined  08-21-2007
sophistry - 23 April 2012 05:46 PM

try set_message_class(‘peeker_body’) and use the direect call to message() method instead of get_message().

then you have to use get_body() to avoid getting the attachments.

Hi ! It works like a charm ! Thanks a lot Sophistry for this work, very helpful !

Bye

Profile
 
 
Posted: 10 May 2012 04:23 AM   [ Ignore ]   [ # 86 ]  
Summer Student
Total Posts:  4
Joined  05-10-2012

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 =)

Profile
 
 
Posted: 12 May 2012 10:36 AM   [ Ignore ]   [ # 87 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1101
Joined  08-06-2006

Hi @Rwkzejedi! Welcome to CI.

Sorry for the delay. The email notification got trapped in my spam folder.

Thank you for the details and code - that is a great help to getting to the root of the problem.

I was able to create a directory in the application APPPATH directory and sucessfully set the path.

Perhaps the APPPATH is set wrong?
Look at the APPPATH:

print_r(APPPATH); 

Look at the output of peeker’s trace() method:

print_r($this->peeker->trace()); 

It will probably say something like this: “Directory not writeable”

Let us know if you need more help!

 Signature 

peeker email (imap/pop) | site_migrate | OOCalendar | PhotoBox2 | word_limiter

Profile
 
 
Posted: 14 May 2012 03:07 AM   [ Ignore ]   [ # 88 ]  
Summer Student
Total Posts:  4
Joined  05-10-2012

Hi Sophistry…

I am ashamed. I missed a lettre in in the folder name ... (attachments / attachements)

I need more sleep.

It works like a charm.

How can we retrieve the name of the string MD5?

attachments/md5like/filename.ext

How do I get that name to put a link on the saved file?

Thank you for your help

Profile
 
 
Posted: 14 May 2012 06:47 AM   [ Ignore ]   [ # 89 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1101
Joined  08-06-2006

get_fingerprint()

see https://github.com/sophistry/peeker/blob/master/docs/peeker_header.html

 Signature 

peeker email (imap/pop) | site_migrate | OOCalendar | PhotoBox2 | word_limiter

Profile
 
 
Posted: 14 May 2012 07:04 AM   [ Ignore ]   [ # 90 ]  
Summer Student
Total Posts:  4
Joined  05-10-2012

Nice ^^

I think it’s all for me =) ! Very nice work and thank you for your support

Profile
 
 
   
6 of 7
6