-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify.pl
More file actions
71 lines (57 loc) · 1.48 KB
/
verify.pl
File metadata and controls
71 lines (57 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/local/bin/perl
# from http://www.mpgh.net/forum/655-realm-mad-god-help-requests/738102-anyone-know-http-post-url-2.html#post8811904
#
# configured for gmail server
#
#
#requirements:
# libnet-imap-simple-perl libnet-imap-simple-ssl-perl liburi-find-perl
#
# usage:
# perl verify.pl
#
# to do:
# add threading
# search for unread messages only
use strict;
use warnings;
use LWP::UserAgent;
use Net::IMAP::Simple::SSL;
use URI::Find;
require "config.pl";
my $server = new Net::IMAP::Simple::SSL('imap.gmail.com:993', use_ssl => "true") || die "Unable to connect to IMAP.\n";
my $email = get_email();
my $password = get_password();
if(!$server->login($email,$password)){
print STDERR "Login failed: " . $server->errstr . "\n";
exit(64);
}
my $i = $server->select('INBOX') + 1;
print "$i messages found";
while ( $i-- ) {
if ( !$server->seen($i) ) {
print "message $i";
my $finder = URI::Find->new( \&acceptVerification );
my $txt = $server->get($i);
$finder->find( \$txt );
}
}
sub acceptVerification {
my $uri = shift;
my $ua = LWP::UserAgent->new;
$ua->env_proxy;
$ua->timeout(30);
my $tmp;
if ( $uri =~ /appspot/ ) {
my $response = $ua->get($uri);
if ( $response->is_success ) {
$tmp = $response->decoded_content;
if ( $tmp =~ /Thank/ ) {
print "ok\n";
}
else {
print "sux\n";
}
}
}
}