Guest User

Untitled

a guest
Jul 7th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. ############################################################
  2. #### BASTARD::IMAP
  3. #### v1.00
  4. #### (C)2009 Warbucks Heavy Industries, LLC
  5. ############################################################
  6.  
  7. package BASTARD::IMAP;
  8.  
  9. our $VERSION = '1.00';
  10.  
  11. use MooseX::AttributeHelpers;
  12.  
  13. use Net::IMAP::Simple;
  14.  
  15. with qw(
  16. MooseX::LogDispatch::Levels
  17. );
  18.  
  19. has logger => (
  20. metaclass => 'NoGetopt',
  21. isa => 'Log::Dispatch::Config',
  22. is => 'rw',
  23. lazy_build => 1,
  24. );
  25.  
  26. has _servername => (
  27. isa => 'Str',
  28. is => 'ro',
  29. default => sub { 'imap.gmail.com' },
  30. );
  31.  
  32. has username => (
  33. isa => 'Str',
  34. is => 'ro',
  35. );
  36.  
  37. has password => (
  38. isa => 'Str',
  39. is => 'ro',
  40. );
  41.  
  42. has unread => (
  43. isa => 'Int',
  44. is => 'ro',
  45. default => sub { 0 },
  46. );
  47.  
  48. has _imap => (
  49. isa => 'Net::IMAP::Simple',
  50. is => 'rw',
  51. accessor => 'imap',
  52. lazy_build => 1,
  53. );
  54.  
  55. sub _build__imap {
  56.  
  57. my ($self) = @_;
  58.  
  59. my $i = Net::IMAP::Simple->new($self->_servername);
  60. $i->login($self->user, $self->pass);
  61. $self->unread = $i->select('INBOX');
  62. return $i
  63. }
  64.  
  65. 1; # End of BASTARD:IMAP
Add Comment
Please, Sign In to add comment