Part of the EllisLab Network
This thread is a discussion for the wiki article: peeker
   
1 of 7
1
peeker
Posted: 11 August 2011 09:50 PM   [ Ignore ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1101
Joined  08-06-2006

Hi!

This is the first post on this wiki article because if you don’t (as the author of a wiki page) make a first post, then you’ll never know if someone starts talking about it…

Hope you like peeker. Please give me feedback.

And if you want help with something: MAKE SURE you POST CODE. grin

 Signature 

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

Profile
 
 
Posted: 31 August 2011 11:24 AM   [ Ignore ]   [ # 1 ]  
Summer Student
Total Posts:  7
Joined  12-17-2010

I was pretty excited to have come across your library—but I’m having trouble implementing it. I’m using CodeIgniter 2.0.3. Is there any other special setup I’m missing?

-Thank you!

Profile
 
 
Posted: 31 August 2011 12:15 PM   [ Ignore ]   [ # 2 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1101
Joined  08-06-2006
sophistry - 12 August 2011 01:50 AM

And if you want help with something: MAKE SURE you POST CODE. grin

Please POST CODE if you want assistance. grin

 Signature 

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

Profile
 
 
Posted: 31 August 2011 01:15 PM   [ Ignore ]   [ # 3 ]  
Summer Student
Total Posts:  7
Joined  12-17-2010

smile Basically I tried the test function recommended by the documentation.

class Test_read extends CI_Controller {
    
public function index() {
        
echo 'test';
        
        
// this shows basic IMAP, no TLS required
        
$config['login']='?@gmail.com';
        
$config['pass']='password';
        
$config['server']='imap.gmail.com: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());
    
}

Here is the result/error message:
A PHP Error was encountered
Severity: Notice
Message: Undefined index: host
Filename: libraries/peeker_connect.php
Line Number: 55

A PHP Error was encountered
Severity: Notice
Message: Undefined index: port
Filename: libraries/peeker_connect.php
Line Number: 56

And “the story of the connection”:
No messages waiting.Array ( [0] => Can’t open mailbox {:/imap/ssl/novalidate-cert}INBOX [1] => Not connected. No email resource at: {:/imap/ssl/novalidate-cert}INBOX [2] => Connection could not be closed. No Mail resource. )

Profile
 
 
Posted: 31 August 2011 01:41 PM   [ Ignore ]   [ # 4 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1101
Joined  08-06-2006

ok! great. now i can easily see what is happening. and i have to apologize - the sample code in the docs is not in synch with the latest version of peeker… i will fix the docs.

the proper usage is below. basically, instead of using one ‘server’ parameter it now uses two (host and port):

OLD:

$config['server']='imap.gmail.com:993'

NEW:

$config['host']='imap.gmail.com'
$config['port']='993'

i believe that is what is causing the errors. let me know!

EDIT: updated bitbucket repo - thanks for the feedback. grin

 Signature 

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

Profile
 
 
Posted: 31 August 2011 02:14 PM   [ Ignore ]   [ # 5 ]  
Summer Student
Total Posts:  7
Joined  12-17-2010

Nice. It’s working now. This is awesome!

Profile
 
 
Posted: 01 September 2011 12:55 PM   [ Ignore ]   [ # 6 ]  
Summer Student
Total Posts:  13
Joined  02-02-2010

Dear sophistry,

i am testing your great library - everything is working like a charm but still one thing dont work for me .

I want to process only unread emails and then mark them as read. I am using IMAP and still getting all emails (read and unread).

Here is my code:

/config/peeker.php

$config['login']='xxx@xxx.sk';
$config['pass']='xxxxx';
$config['host']='localhost';
$config['port']='993';
$config['service_flags''/imap/ssl/novalidate-cert';
$config['mailbox''INBOX'

/controllers/test.php

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

if (
$this->peeker->message_waiting())
{
    $message_count 
$this->peeker->get_message_count(); 
    
debug_var($message_count);
    
$ems $this->peeker->get_message('1'$message_count); 
    
debug_var($ems);
}
else
{
echo 'No messages waiting.';
}

$this
->peeker->close(); 

... and i am still getting all that emails… How i can achieve to hide readed emails from processing without need to store some information in db?

Profile
 
 
Posted: 01 September 2011 01:30 PM   [ Ignore ]   [ # 7 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1101
Joined  08-06-2006

try this:

$this->peeker->flag_mail($message_num,'\\Seen'); 

EDIT:
or this ($e is an email message object):

$e->flag_seen(); 

let me know if that works. i’ve been relying on gmail’s INBOX handling on IMAP so this happens automatically.

cheers.

 Signature 

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

Profile
 
 
Posted: 01 September 2011 01:52 PM   [ Ignore ]   [ # 8 ]  
Summer Student
Total Posts:  13
Joined  02-02-2010

Yes, that will mark them as read, but still i am getting all that read mails. I think that behaviour depends on mail server settings. I have my own mail server, but i dont want to mess with that settings so I will try to use set_search function for finding unread mails.

But still thanks for your very fast response and for your great library smile

Profile
 
 
Posted: 01 September 2011 02:43 PM   [ Ignore ]   [ # 9 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1101
Joined  08-06-2006

How about this:

$e->flag_seen_move_mail('mailbox_name'); 
 Signature 

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

Profile
 
 
Posted: 13 September 2011 05:36 PM   [ Ignore ]   [ # 10 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  415
Joined  10-20-2008

Managed to get this running, however message_id never gets set, can you take a look smile

 Signature 

Mat-Moo
Image moo - the easy to use image library!
MatMoo.com!
E-Mail Remind - Free reminders by email
Printfetti - Your photos on confetti!

Profile
 
 
Posted: 13 September 2011 05:44 PM   [ Ignore ]   [ # 11 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1101
Joined  08-06-2006

please post code.

 Signature 

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

Profile
 
 
Posted: 13 September 2011 06:03 PM   [ Ignore ]   [ # 12 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  415
Joined  10-20-2008
if ($this->peeker->message_waiting())
        
{
            $message_count 
$this->peeker->get_message_count();
            print 
"Found $message_count  ";
            
$ems $this->peeker->get_message('1'$message_count);
            foreach(
$ems as $email)
            
{
                
print "<hr>";
                
print_r($email);
                
$x $email->header_string;
                
$y explode("\r\n"$x);
            
}
        } 

print_r($email) never has a message id - however as I’m checking for bounces I don’t think this will be set to the correct value anyway. Never mind.

 Signature 

Mat-Moo
Image moo - the easy to use image library!
MatMoo.com!
E-Mail Remind - Free reminders by email
Printfetti - Your photos on confetti!

Profile
 
 
Posted: 13 September 2011 06:53 PM   [ Ignore ]   [ # 13 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1101
Joined  08-06-2006

yes. there are actually several “message identifiers” in peeker.

the standard mime-mail message-id header is one of them, but as you see it is not set by the mail transport in certain circumstances so it comes in blank or like this: <>.

another “message identifier” in peeker is the $Msgno property which has the numerical index of the message in the context of the current mail getting sequence/request - it is not a fixed value but comes as an aftereffect of the order of the messages on the IMAP or POP server.

and finally there is the $fingerprint “message identifier” which is an attempt to make it easy to create a unique KEY has based on developer-defined email charactersistics that get fed into a hash.

cheers.

 Signature 

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

Profile
 
 
Posted: 13 October 2011 06:43 AM   [ Ignore ]   [ # 14 ]  
Summer Student
Total Posts:  4
Joined  10-13-2011

Hello and thanks for this library.

I am trying to perform a search and depending on the search result i want to retrieve some minor (subject, date etc) header information.

$config['login']='user@domain.com';
$config['pass']='xxxxxx';
$config['host']='mail.domain.com';
$config['port']='XXX';
$config['service_flags''/imap/notls';
$config['mailbox''INBOX';

$this->load->library('peeker/peeker'$config);
$this->peeker->set_search('FROM "name@email.com"');
$search_result $this->peeker->get_ids_from_search();

foreach(
$search_result as $v)
{
  $ems 
$this->peeker->get_message($v);
  
$messages[$v]['subject'$ems->subject;  
  
$messages[$v]['date'$ems->date;
  
$messages[$v]['sender'$ems->senderaddress;

Above is the code i would use, but unfortunately “get_message” returns a big object and is very memory intensive.
Is there any other way to receive a list of search rusult messages?

Thanks for your advice.

 

Profile
 
 
Posted: 13 October 2011 08:10 AM   [ Ignore ]   [ # 15 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1101
Joined  08-06-2006

hi ldz and welcome to CI!

yes, if you ONLY want header information (to conserve memory for instance) you can use a slightly different approach to do it.

DO NOT use the get_message() function; use message() instead.

1) set the message class that you want peeker to use to handle the messages. in your case it is the peeker_header class in the included peeker_header.php file. that class will ONLY access the header data for an email - not any body data.

2) get the email object using the message() function rather than get_message()

//peeker_header.php file must be in same directory as peeker.php (it is there in the default source distribution)
$this->peeker->set_message_class('peeker_header');
// get just the headers of the first email message
$email_object $this->peeker->message(1); 

if you have any problems check the documentation or post code here.

good luck and let us know how it goes.

cheers.

 Signature 

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

Profile
 
 
   
1 of 7
1