Advertisement
Guest User

Untitled

a guest
Nov 2nd, 2015
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. # gimap.pl by gxmsgx
  4. # description: get the count of unread messages on imap
  5.  
  6. use strict;
  7. use Mail::IMAPClient;
  8. use IO::Socket::SSL;
  9.  
  10. my $username = 'example.username';
  11. my $password = 'password123';
  12.  
  13. my $socket = IO::Socket::SSL->new(
  14. PeerAddr => 'imap.server',
  15. PeerPort => 993
  16. )
  17. or die "socket(): $@";
  18.  
  19. my $client = Mail::IMAPClient->new(
  20. Socket => $socket,
  21. User => $username,
  22. Password => $password,
  23. )
  24. or die "new(): $@";
  25.  
  26. if ($client->IsAuthenticated()) {
  27. my $msgct;
  28.  
  29. $client->select("INBOX");
  30. $msgct = $client->unseen_count||'0';
  31. print "$msgct\n";
  32. }
  33.  
  34. $client->logout();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement