I am trying to build an autoresponder script for sendmail (no, I don't want to use a pre-built one yet), but I can't seem to find the location of received emails on my server. I have to specify that my configuration is not a default one.

I've looked in /root, there is no mail folder there. (I don't have any other user than root). I've looked in /var/mail/root, there are just some logs which are sent to me by mail, but not external mail that I receive from users.

I've checked /var/log/maillog, but there are no errors.

I'm out of ideas where to look. Could anyone help me?

3 Answers 3


sendmail (a mail transport agent - MTA) stores mail in the place where it is configured to store mail. But an MTA only stores mail which it is currently queueing - delivery of mail to the location where it is accessible by a user is handled by the mail delivery agent (MDA). While sendmail (and other MTAs) can act as an MDA, it's very unusual for that to be the case.

Regardless, trying to access the mail files is not the right way to implement an autoresponder.

This should be done as a filter in the MTA (i.e. a milter) or in the MDA. The milter API is specifically designed for this - and there may already be tools available which would meet your requirement with no modification.

If your current MDA is procmail then in you're in luck - this provides a huge amount of flexibility (indeed its a programming language in its own right) for handling mail messages. Again there is lots of code on the internet which may meet your needs (AFAIK there is no central respository for procmail recipes - but try google).

Even the basic .forward mechanism can be used to implement this - but I'd advise against this - goingdown the procmail route you can fork the message so that delivery is not dependent upon/implemented by your script.

  • I do have procmail installed (procmail-3.22-17.1.el5.centos.x86_64), but I'm not sure it is used. I've also read about an auto-reply script that uses procmail, which could be useful for me. Can I see if procmail is in use? Oct 5, 2011 at 11:56
  • 1
    Could you post the contents of your sendmail.cf file around the line that starts Mlocal, which will tell us what MDA is in use.
    – MadHatter
    Oct 5, 2011 at 12:08
  • Yes, it's procmail. Yaay! P=/usr/bin/procmail is the code. Thank you :) Oct 5, 2011 at 20:29
  • But I have no procmailrc file. Makes me wonder if my sendmail+procmail are really used. Oct 5, 2011 at 20:36
  • If its configured in sendmail and your mail is getting delivered then its using procmail (with the compiled in defaults). See the man page for procmail - usually it chacks for /etc/procmailrc and ~/.procmailrc and if neither are found then it delivers the mail according to the config at compile time.
    – symcbean
    Oct 6, 2011 at 12:33

If you have other than default directories configured, you should look at your /etc/mail/sendmail.cf to see what the paths are set to.

Not only does this vary betweeen OS distribution, but even the default directories between different versions of sendmail changed. In short, just for us to tell you the defaults, we need to know the OS version AND the sendmail version. Defaults are /var/spool/mail/$USERNAME for the mail drop, then if a user reads the mail with another application it is usually moved to $HOME/mbox.

Here is a list of common mail directories:

  • /var/mail/$USERNAME
  • /var/spool/mail/$USERNAME
  • $HOME/mbox
  • $HOME/mail
  • $HOME/Maildir
  • Thanks, but under which variable name should I look it up in the config file? I've read something about $MAIL = but I can't find it in the config file. I've checked /var/spool/mail/root, there are some mails in there, but not the right ones (and I'm sure they've not been read, since I sent an email and quickly checked the file -- wasn't there). Oct 5, 2011 at 11:41

It depends on how it's configured, but the usual place is /var/spool/mail, or some distros /var/mail. If it's in neither of those places, let us know, and we'll start digging!

  • There are some mails in /var/spool/mail/root but only the local mails (sent from root to root). Oct 5, 2011 at 11:56
  • What else is in /var/spool/mail?
    – MadHatter
    Oct 5, 2011 at 12:09
  • A file named rpc which is totally empty. Oct 5, 2011 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.