Advertisement
pulser_777

Untitled

Apr 7th, 2019
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.71 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. use Net::IMAP::Client;
  7.  
  8. my $imap = Net::IMAP::Client->new(
  9.         server => 'imap.gmail.com',
  10.         user => 'foo@example.com',
  11.         pass => 'foobar',
  12.         ssl => 1,
  13.         ssl_ca_path => '/etc/ssl/certs/',
  14.         port => 993,
  15. ) or die "Can't connect to imap.gmail.com.";
  16.  
  17. $imap->login or die "Can't login to imap.gmail.com. " . $imap->last_error;
  18. $imap->select('INBOX');
  19.  
  20. my $msg = $imap->search({from => 'info@point.gmo.jp'});
  21. print scalar(@$msg) . " messages.\n";
  22.  
  23. $imap->delete_message($msg) or die "Failed to delete messages. " . $imap->last_error;
  24. $imap->expunge() or die "Failed to expunge messages. " . $imap->last_error;
  25.  
  26. $imap->logout;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement