PAM_MAIL(8)

โœจ PAM_MAIL โœจ (that's section 8 of the manual, bestie)

okay so real quick, this page lives in the Linux-PAM Manual and it's about pam_mail, which is genuinely one of the cutest little PAM modules out there. let's get into it ๐Ÿ’Œ


๐Ÿ’– NAME ๐Ÿ’–

pam_mail โ€” it tells you about mail you have. that's it. that's the whole job. and it ate.


๐ŸŒธ SYNOPSIS ๐ŸŒธ

pam_mail.so [close] [debug] [dir=maildir] [empty] [hash=count] [noenv]
            [nopen] [quiet] [standard]

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so pam_mail is the PAM module that serves up the iconic "you have new mail" moment to the user. literally its whole personality. you can plug it into any application that has credential or session hooks โ€” it's flexible like that ๐Ÿ’…

what it does: it gives you a single message that tells you how new the mail it found in the user's mail folder is. one message. no spam. we love that.

and that's not all โ€” this module also sets the PAM environment variable, MAIL, pointing at the user's mail directory. so it's useful and it sets you up. main character behaviour, honestly.

๐Ÿซถ tiny detail that matters: if the mail spool file is actually a directory โ€” whether that's /var/mail/$USER or whatever pathname you handed over with the dir= parameter โ€” then pam_mail just assumes you're living that Maildir format life.

๐ŸŽ€ OPTIONS ๐ŸŽ€

one bullet per flag, no skips, we don't do that here:

  • close โ€” says whether the user has any mail on logout too, not just login. so you get the tea on the way out as well โœจ
  • debug โ€” prints debug information. for when you need to see the receipts.
  • dir=maildir โ€” look for the user's mail somewhere else, in the alternative location defined by maildir/<login>. the default location for mail is /var/mail/<login>. heads up though: if the maildir you supply starts with a '~', the directory is interpreted as indicating a file in the user's home directory ๐Ÿ 
  • empty โ€” also print the message if the user has no mail. yes, even the empty-inbox girlies get acknowledged.
  • hash=count โ€” mail directory hash depth. for example, a hashcount of 2 would make the mail file be /var/spool/mail/u/s/user. cute little nested situation.
  • noenv โ€” do not set the MAIL environment variable. sometimes you just don't want it, and that's valid.
  • nopen โ€” don't print any mail information on login. this flag is useful when you want the MAIL environment variable set, but you don't want to display any information about it. silent but working, iykyk.
  • quiet โ€” only report when there is new mail. no new mail, no talking. periodt.
  • standard โ€” the old style "You have..." format, which doesn't show the mail spool being used. this also implies "empty" ๐Ÿ’ซ

๐ŸŒˆ MODULE TYPES PROVIDED ๐ŸŒˆ

the session and auth module types are provided โ€” and for auth, that's on establishment and deletion of credentials. so it's showing up at the beginning and the end of the vibe. iconic.


โญ RETURN VALUES โญ

the glow-up report card:

  • PAM_BUF_ERR โ€” memory buffer error ๐Ÿ˜ญ
  • PAM_SERVICE_ERR โ€” badly formed arguments (the flags got messy)
  • PAM_SUCCESS โ€” success ๐Ÿ’–
  • PAM_USER_UNKNOWN โ€” user not known ๐Ÿคท

๐Ÿ’… EXAMPLES ๐Ÿ’…

drop this line into /etc/pam.d/login so the user gets told they have new mail when they log in to the system:

session  optional  pam_mail.so standard

๐Ÿ“ SEE ALSO ๐Ÿ“

pam.conf(5), pam.d(5), pam(8)


๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

pam_mail was written by Andrew G. Morgan <morgan@kernel.org>. we stan a legend ๐Ÿซถ


and that's the whole page, bestie! this one came from the Linux-PAM crew and it's dated 09/27/2026 โ€” so yeah, freshly stamped, still slaying. go set your MAIL variable and have the best day, mwah ๐Ÿ’‹โœจ

๐Ÿ“ฆ where this page comes from