Fix | Janne Honkonen - Janne Honkonen - Official pages of the Janne Honkonen, visual artist

Postfix repairing and fixing cheatsheet

Linux is fun. Configuring services on Linux is fun. Fixing problems and trying to find wrong settings in Linux is fun. Err — screw that, who am I kidding.

Finding problems when setting up certain services in Linux can be quite difficult, specially when you are trying to fix any mail-service related problems. This is why, years ago, I created a cheat sheet for future myself should I ever encounter certain mail-service related problems. Now I wish to share this cheat sheet with all of you.

Following article can help you find and fix up the problems with the Postfix mail service in Linux operating systems.

Cheat sheet for Postfix troubleshooting

One of the most often problems I ever have encountered with Postfix, and it’s companions such as Courier, is that user cannot authenticate / login into server for receiver or sending emails. Often mail clients simply state: “Cannot login” or “Wrong password or credentials” or something like this on the category “That does not help me a s*hit”. Here is the checklist to go through when receiving postfix/courier authentication problems.

  • Getting good diagnostics tools
    • One good way to find problems is using MUTT (apt-get install if missing) and run command mutt -f imap://localhost/
    • Other good diagnostic tool is installing web-mail software, such as Squirrelmail
  • Are the correct mail services running?
    • Is the Postfix – service running (in Debian, check /etc/init.d/postfix status)
    • Is the Authentication services running (such as salsauth)
  • Does the user actually exists in your mail-users database?
    • DB / MySQL based user base
      • Check that the user exists in mailbox – table
      • Spellcheck! Check that typing is correct: user@domain.tld
    • Postfix look-up tables
      • Is the files in correct format?
      • Have you remember to postmap the files?
  • Does the virtual mail directory for the mail user exists?
    • If you are using database solution, check that the directory (maildir) is correct and with TRAILING slash, otherwise all your mail may go to a single file instead of multiple files in the mail directory.
    • Does the actual directory even exists? Are you sure? Doublecheck name and location!
  • Does the mail directories and files have the correct owner and ground?
    • Owner and group for all virtual mailboxes and their files as well as directories should be postfix:postfix so the Postfix can handle them.
      • Check the owner with ls -l /var/mail/virtual .. and any needed subdirs. User and group should be postfix:postfix
      • You can fix this quickly using command chown -R postfix:postfix /var/mail/virtual
  • Is the UID and GID number (User ID and Group ID) correct in Postfix settings?
    • Number of UID represents user’s number as well as GID represents group’s number. As Postfix needs to handle the mail, both directories and files as well as configuration should all point that Postfix owns all and users all.
    • Check that mail database (MySQL or look-up tables) uses correctUID and GID
      • To find out correct numbers, use command id -u postfix for user and id -g postfix for group
      • To check what authentication uses, try authtest user@domain.tld to see needed UIDs and GIDs
  • For Postfix MySQL, Is the socket correct?
    • Sometimes Postfix has a hard time to find correct MySQL connection socket.
      • Check MySQL Virtual maps that the HOSTS setting is correct.
      • Possible solutions are localhost, 127.0.0.1 or specified unix socket file
  • Still problems?
    • Check /var/log/mail.log log-file with nano or tail command. Use tail -f /var/log/mail.log to keep it running
    • Check /var/log/syslog main system log for errors
    • Google it. If these cheat sheet instructions do not help, try googling the error. It always helps because there most certainly has been someone having same issues as you long before you even thought of installing Postfix into use 🙂

Hope this cheat sheets helps with your problems. Feel free to add link to this article if this helps you 🙂

© Janne Honkonen - www.jannehonkonen.com