FogBugz 4.0 Cannot Send or Receive Email (read this article before others)

FogBugz 4.0 uses a service called the FogBugz Maintenance Service to, among other things, send and receive email, so if you're having problems with both sending and receiving then this is the first thing to look at. (On non-Windows FogBugz this is called the fogbugzmaintd daemon.)

First, log into FogBugz and click Send Mail, and send an email to yourself at an address that you can rely on for fast delivery (note that website mail services like Hotmail and Yahoo can have their own random delays). Type "email test" in the body of the email. If you receive that email at any point during the following steps then you've fixed the problem.

1. Look at the FogBugz Maintenance Service in the Windows Services control panel (on non-Windows platforms this is the fogbugzmaintd daemon). Is it running? That is responsible for, among other maintenance tasks, delivering mail. It has to be running for FogBugz to work. If it is not running, start it, and you have now probably fixed the problem. If it is running, restart it. Either way, you may need to then wait for a few minutes to allow it to work through its queue of tasks. Not all the tasks in its queue are mail tasks, so it may be running and just not delivering mail for a minute or two.

2. Go to the MailQueue table in your FogBugz database and view all rows in the table. Any undelivered outgoing email will be sitting here. If there are rows here, we now know there is mail that is not being delivered at all. Leave this open so you can look at it later. You should see your test email with the words "test email" in the sMessage column, probably in the bottom row.

3. Look at the "Maintenance URL" on the Site page (log into FogBugz as an admin and click Site top right).  Sit down in front of the FogBugz server machine and log on.  Paste this URL into a browser process running on the web server itself -- not your local computer. If the page cannot be displayed, that's the problem, and you will need to adjust the settings of your web server to allow it to load that URL (or, use a URL that can be loaded for the "Maintenance URL"). This URL is what the Maintenance Service uses to connect to FogBugz and grab the next email to deliver.

4. Check the dtLastChecked setting.  This setting lives in the Setting table in the database and should be a date relatively recent.  If it is set way in the future because the server's clock had been changed, reset it to today's date and time.  The FogBugz maintenance service will not run again until dtLastChecked has passed.  (On older versions of FogBugz, this setting lives in the registry under HKLM\Software\Fog Creek Software\FogBugz\[path to fogbugz])

5. If your FogBugz site is served over SSL, be sure to log in as the user you installed FogBugz as, and load up the FogBugz Maintenance URL in Internet Explorer.  If you get prompts, say yes to all the messages, log out and log back in again.  Then try again and make sure you do not get any prompts.  You may need to import your certificate to the Trusted Root store so that IE doesn't prompt you at all (if it is prompting you, that means it is prompting the maintenance service, and it doesn't know how to respond to those prompts).

The above are the main areas of problems for new 4.0 installations. You'll know when things are fixed when rows start disappearing from the MailQueue table.

Further troubleshooting: 

Bring up FogBugz in any browser and connect to your-fogbugz-url/heartbeat.asp. (That's heartbeat.php on non-Windows platforms.)

Bring up FogBugz in any browser and connect to your-fogbugz-url/diagnostics.asp. Run through all the steps. The mail tests are steps 6 and 7.

If you're still having problems with email sending/Notifications, continue with this guide.

If you're still having problems with email receiving/Mailbox, continue with this guide.