[Discuss] Mailcheck not showing new mail

Bill Horne bill at horne.net
Sun Aug 10 21:41:00 EDT 2014


>Bill Horne wrote:
>> The result of running "mailcheck -cs" without a local .mailcheckrc is
>> "no new mail." when there is mail in the mailbox, and no output when the
>> mailbox is empty. It *is* paying attention to the mail spool, albeit not
>> in the way I want. What's up with that?

>> ...why it would be able to tell the difference between a spool file
>> with <anything> in it, or <nothing> in it, but not signal if the file
>> has new mail?

> With Maildir detecting new mail is simply a matter of looking for the
> presence of files in a 'new' subdirectory. If I recall, with mbox
> files the file has to be parsed and the headers of each message
> examined.  There needs to be coordination between how the MUA marks
> messages as read and the mail checking tool. Maybe there is a
> disagreement between mailcheck and your MUA.

> The documentation on mailcheck seems sparse. It doesn't even state
> what the default behavior is if there are no config files. To
> understand what it is doing would require using strace and/or
> examining the source.

> (I'd try running "strace -o/tmp/mailcheck ..." then grep
> /tmp/mailcheck for /var to see what spool files it is accessing. If
> you spot an open() syscall, it'll return a file descriptor, and then
> you can look for subsequent syscalls (like read() and stat()) on that
> descriptor to see what it is doing with the file.)

Here's the output file after I renamed .mailcheckrc: /etc/mailcheckrc has only comments.

execve("/usr/bin/mailcheck", ["mailcheck"], [/* 21 vars */]) = 0
brk(0)                                  = 0x82c000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4dca743000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=24081, ...}) = 0
mmap(NULL, 24081, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f4dca73d000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320\37\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1845024, ...}) = 0
mmap(NULL, 3953344, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f4dca15d000
mprotect(0x7f4dca319000, 2093056, PROT_NONE) = 0
mmap(0x7f4dca518000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1bb000) = 0x7f4dca518000
mmap(0x7f4dca51e000, 17088, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f4dca51e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4dca73c000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4dca73a000
arch_prctl(ARCH_SET_FS, 0x7f4dca73a740) = 0
mprotect(0x7f4dca518000, 16384, PROT_READ) = 0
mprotect(0x7f4dca745000, 4096, PROT_READ) = 0
munmap(0x7f4dca73d000, 24081)           = 0
brk(0)                                  = 0x82c000
brk(0x84d000)                           = 0x84d000
open("/home/moder8/.mailcheckrc", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/mailcheckrc", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=1446, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4dca742000
read(3, "# mailcheckrc\tDefault configurat"..., 4096) = 1446
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0x7f4dca742000, 4096)            = 0
exit_group(0)                           = ?
+++ exited with 0 +++

... and here's the output file after .mailcheckrc was restored: 

execve("/usr/bin/mailcheck", ["mailcheck"], [/* 21 vars */]) = 0
brk(0)                                  = 0x1643000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f19bdc00000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=24081, ...}) = 0
mmap(NULL, 24081, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f19bdbfa000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320\37\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1845024, ...}) = 0
mmap(NULL, 3953344, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19bd61a000
mprotect(0x7f19bd7d6000, 2093056, PROT_NONE) = 0
mmap(0x7f19bd9d5000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1bb000) = 0x7f19bd9d5000
mmap(0x7f19bd9db000, 17088, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f19bd9db000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f19bdbf9000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f19bdbf7000
arch_prctl(ARCH_SET_FS, 0x7f19bdbf7740) = 0
mprotect(0x7f19bd9d5000, 16384, PROT_READ) = 0
mprotect(0x7f19bdc02000, 4096, PROT_READ) = 0
munmap(0x7f19bdbfa000, 24081)           = 0
brk(0)                                  = 0x1643000
brk(0x1664000)                          = 0x1664000
open("/home/moder8/.mailcheckrc", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0664, st_size=101, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f19bdbff000
read(3, "/var/spool/mail/$(USER)\n/home/mo"..., 4096) = 101
stat("/var/spool/mail/moder8", {st_mode=S_IFREG|0660, st_size=0, ...}) = 0
stat("/home/moder8/Mail/obfuscate", {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
stat("/home/moder8/Mail/anonymous", {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
stat("/home/moder8/Mail/ok", {st_mode=S_IFREG|0660, st_size=0, ...}) = 0
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0x7f19bdbff000, 4096)            = 0
exit_group(0)                           = ?
+++ exited with 0 +++


>> Also check to see if /etc/mailcheckrc exists and see what it points to.
>> 
>> Another puzzle: on Ubuntu 14.04 LTS, it's all commented out. There is an
>> entry that looks like
>> 
>> #/var/spool/mail/$(USER)

> By convention, a commented out config line often will indicate the
> compiled-in defaults. (You can confirm that by running something like
> "strings /usr/bin/mailcheck | fgrep /var" and see if it spits out a
> similar looking path.)

> That would imply it should work as expected without altering
> /etc/mailcheckrc or adding an rc file. But you're saying you didn't
> get the expected behavior until you added "/var/mail/moder8" to
> .mailcheckrc?

I didn't get any "new mail" indication until I installed my own
.mailcheckrc file: prior to that, mailcheck would show "no new mail."
if there was /any/ email in /var/mail/(my user id), and would give a
(blank) result if the spool email file was empty.

I ran 

"strings /usr/bin/mailcheck >/tmp/mailcheck_output.txt"

... while .mailcheckrc was absent. Here is the output, which does /not/
have "/var" in it.

/lib64/ld-linux-x86-64.so.2
__gmon_start__
libc.so.6
socket
fflush
strcpy
exit
readdir
fopen
strncmp
strrchr
__strdup
perror
connect
closedir
strncpy
puts
__stack_chk_fail
getpw
fgets
strlen
strstr
herror
getopt
fclose
__strtol_internal
malloc
strcat
opendir
getenv
__ctype_b_loc
sscanf
optarg
stderr
gethostbyname
fwrite
strchr
fprintf
fdopen
__xstat
strcmp
__libc_start_main
snprintf
free
GLIBC_2.4
GLIBC_2.3
GLIBC_2.2.5
%z4 
%r4 
%j4 
%b4 
%Z4 
%R4 
%J4 
%B4 
%:4 
%24 
%*4 
%"4 
=i3 
ATUH
[]A\A]A^A_
|$	O
|$	R
fffff.
$INBOfA
T$ H
Ot~H
=j) 
*t1H
=	) 
T$ H
=l' 
+t7H
+t&H
='& 
AUATUS
[]A\A]L
[]A\A]L
ffffff.
AVAUI
[]A\A]A^
=n# 
ffff.
ffffff.
ATUSH
=j  
="  
D$HH9D$XHc
[]A\
[]A\
~|Hc
D$HH9D$X
[]A\
ffffff.
l$ H
fffff.
AVAUATUSH
t$ E1
t/E1
[]A\A]A^A_
\$ H
l$(L
d$0H
fffff.
l$ L
t$(L
|$0H
Usage: mailcheck [-bchls] [-f rcfile]
Options:
  -b  - brief output mode
  -c  - use more advanced counting method for mboxes and maildirs
  -l  - login mode, honor ~/.hushlogin file
  -s  - show "no mail" summary, if no new mail was found
  -f  - specify alternative rcfile location
  -h  - show this help screen
mailcheck: failed to stat file: %s
mailcheck: unable to open mbox %s
error: couldn't open rcfile '%s'
mailcheck: couldn't open /etc/mailcheckrc nor %s/.mailcheckrc
mailcheck: WARNING! %s may be readable by other users.
mailcheck: Type "chmod 0600 %s" to correct the permissions.
mailcheck: WARNING! %s could not be read.
mailcheck: Unable to get login information for %s
mailcheck: Not Connected To Server '%s:%d'
mailcheck: Unable to check IMAP mailbox '%s@%s:%d'
a003 STATUS %s (MESSAGES UNSEEN)
mailcheck: Error Receiving Stats '%s@%s:%d'
* STATUS %*s (MESSAGES %d UNSEEN %d)
mailcheck: Invalid User Name '%s@%s:%d'
mailcheck: Incorrect Password for user '%s@%s:%d'
mailcheck: Error Receiving STAT '%s@%s:%d'
mailcheck: ooops, unsupported experimental info semantics on %s/%s
You have %d new and %d unread messages in %s
You have %d unread messages in %s
%s: %d new and %d unread message(s)
%s: no new mail, %d unread message(s)
mailcheck: %s is not a valid maildir -- skipping.
You have %d new and %d saved messages in %s
You have %d new messages in %s
%s: %d new and %d saved message(s)
mailcheck: error, %s is not mbox or maildir
mailcheck: invalid line '%s' in rc-file
You have %d saved messages in %s
mailcheck: couldn't read environment variable HOME.
bchlsf:
%s/%s
>From 
Status: 
%s/.mailcheckrc
/etc/mailcheckrc
%s/.netrc
pop3
imap
USER
a001 LOGIN %s %s
a002 LOGOUT
mailcheck: Server said %s
a004 LOGOUT
USER %s
QUIT
PASS %s
STAT
+OK %d
LAST
%s/new
%s/cur
new 
You have %smail in %s
contains saved 
%s: %smail message(s)
%s: %d new message(s)
pop3:
imap:
%s: %d saved message(s)
HOME
%s/.hushlogin
no new mail
No new mail.
password
macdef
default
user
machine
passwd
account
mailcheck: %s:%d: warning: unknown token "%s"
mailcheck: %s:%d: warning: found "%s" before any host names
gethostbyname
Error opening socket
Error connecting


Thanks for your help!

Bill

--
E. William Horne
William Warren Consulting
339-364-8487



More information about the Discuss mailing list