-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcheckmail
executable file
·53 lines (46 loc) · 1.57 KB
/
checkmail
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
#!/usr/bin/perl -lw
##
## Checks mboxes for unread mail.
## Copyright (c) 2005 by Stanislaw Klekot (dozzie/AT/irc.pl)
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, see <http://www.gnu.org/licenses/>.
##
## This is part of Tiny Applications Collection
## -> http://tinyapps.sourceforge.net/
##
# Script checks if specified mailboxes (mbox format) contain not yet read
# mail. Not read mail is such that doesn't have "Status:" header or has "O"
# there.
#
# Invokation: $0 mailbox ...
MAILBOX: foreach $mailbox (@ARGV) {
open MAIL, $mailbox or do {
print STDERR "Can't open mailbox: $!";
next MAILBOX;
};
until (eof MAIL) {
$status = "";
do {
chomp($_ = <MAIL>);
$status = $1 if /^status:\s*(.*)/i;
} while ($_ ne "");
if ($status eq "O" || $status eq "") {
$mailbox =~ s{^.*/}{};
print "You have mail in $mailbox";
next MAILBOX;
}
do { $_ = <MAIL> } until eof MAIL || /^From .* [A-Z][a-z][a-z] [A-Z][a-z][a-z] \d\d \d\d:\d\d:\d\d \d\d\d\d\s?$/;
}
close MAIL;
}