forked from spicyjack/perl-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremail.pl
26 lines (22 loc) · 791 Bytes
/
remail.pl
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
#!/usr/bin/perl
# script to pop mail and re-mail it to another address. basically a scripted
# mail forwarder. Thanks Joann, without your motivation, I would have never
# written something like this...
$pop_server = "localhost";
$username = "raivyn";
$password = "6gieN8tQd";
$pop = Net::POP3->new($pop_server)
or die "Can't open connection to $pop_server : $!\n";
defined ($pop->login($username, $password))
or die "Can't authenticate: $!\n";
$messages = $pop->list
or die "Can't get list of undeleted messages: $!\n";
foreach $msgid (keys %$messages) {
$message = $pop->get($msgid);
unless (defined $message) {
warn "Couldn't fetch $msgid from server: $!\n";
next;
}
# $message is a reference to an array of lines
$pop->delete($msgid);
}