Like so many things in life, oysters defend themselves against being desirable by being potentially deadly. The maxim used to be that it's safe to eat oysters in any month with an "r" in it -- i.e., September -- April. Well, January has an "r" in it, but after a recent mishap, I got curious: when, exactly, is it safe to eat oysters, when not, and what makes an oyster safe to eat anyway? Here is some information for molluskophiles, molluskophiliacs, and molluskophobes.*
What is an oyster? An oyster is an animal that belongs to one of the groups of bivalve mollusks which live in brackish marine habitats and belongs to the species Ostrea, Crassostrea or Saccostrea. From the human perspective, oysters are used as food or to grow pearls (though the oysters that do the one do not typically also do the other).
From the oysters' point of view, food oysters do not fulfill that office just for humans but also other marine life, which may be one reason oysters live in clusters called beds, some of which form reefs as long as fifty miles, and why they live in shells that they can clamp shut against invaders. As for pearl oysters, they have problems of their own and are not patient with hearing the complaints of the food oysters, and it is reaction to this and other irritations that causes the formation of the pearl. Biologically, oysters are a more complex form of marine life than you think when you find them embedded on shaved ice and bathed in mignonette: they breathe, eat, defecate, and reproduce sexually -- often performing that function solo not in the way you're thinking of but by the fact that some species can and do change sexes during their lifespan.
What is a food oyster? Food oysters belong to the family Ostreidae, or "true" oysters. They are harvested from beds simply: by hand, rake or dredge. The safest food oysters come from commercial beds, where, just as with other food animals raised for that purpose, conditions are professionally monitored and managed. To ensure that you are buying legally farmed and harvested oysters, ask your vendor -- whether fishmonger or grocer (see below) -- to see the shipper's tag. This will tell you if the oysters were harvested from approved waters, and list the names and affiliations of the harvester, processor and shipper.
What about an oyster makes me sick?* If you get sick from oysters, it is either due to allergy or bacteria, and be warned: either presence can manifest unannounced. Allergies first: along with nuts, allergy to shellfish is the most common food allergy. Shellfish allergy is divided into two classes: crustaceans (lobster, crab, shrimp, etc.) and mollusks (oysters, clams, mussels, etc.). Shellfish allergy is primarily due to an individual's reaction to tropomyosin, a protein present in shellfish. As a rule, people are who are allergic to one sort of shellfish are not necessarily allergic to all of them; i.e., if you're allergic to mollusks you may or may not be allergic to crustaceans. Further, the allergy may be individuated: i.e., if you're allergic to mollusks it may be only to raw while cooked is fine, or only to oysters but not to clams. Finally, food allergies ebb and flow as do the tides that feed the oyster beds. So the only way to know if you're a) allergic to shellfish and b) what kinds of shellfish c) prepared how is to d) take your allergist to dinner. Or at least make an appointment with one (an allergist, not a mollusk).
As for bacteria, that is vibrio vulnificus, a rod-shaped bacterium that, unlike most bacteria, tolerates salt, making it a natural inhabitant of the same marine environments that also host oyster beds. In healthy people, eating shellfish that hosts the vibrio vulnificus bacteria can lead to a nasty case of food poisoning that can feature vomiting, diarrhea and abdominal pain; but in people with compromised immune systems (especially those with chronic liver disease), the bacteria can infect the bloodstream, causing severe and potentially life-threatening reactions. In occurences of both allergic reaction and bacterial contamination, it is crucial to timely seek qualified medical attention.
How about eating oysters in restaurants or buying them at the grocery store? If you're not allergic to them, you should be safe ordering oysters on the half shell in a restaurant as the restaurant should have gotten the oysters from a reputable fishmonger and should be serving them fresh, discarding any that may be "off" (see below). If in doubt, ask to speak with the chef preparing the dish that night and don't order unless you feel sufficiently reassured. Also don't be shy about testing the oysters at table. You will not look any sillier sniffing a fresh oyster before you pop it into your mouth than you will as the thing, once it passes inspection, slithers down your throat while the liquor dribbles down your chin and the hot sauce makes your eyes water. If you're not allergic and if the oysters are cooked, then you should also be fine as the heat will have destroyed the bacteria if there was any to begin with.
At home, it is best to buy fresh oysters the day you plan to consume them. Buy them from a reputable fishmonger, who aside from speaking to the provenance of the oysters can speak to their qualities, a welcome conversation for the home cook. Oysters should be tightly closed but there will inevitably be a few in the pile that are slightly open -- for these, have the fishmonger or grocery store counter staff do the "tap test": upon tapping, any open shells should close. Don't buy oysters that fail the tap test, and don't buy oysters that are bagged together, as it is impossible to tell which are safe and which not. Keep the oysters ice cold on the way home, and store them in open air (still on ice) once there. Though you might think otherwise, it is harmful to submerge them in water, as they still require oxygen and unless you are a marine biologist you cannot reproduce at home the natural environment that allows them to breathe. Test them again (tap tap) before preparing. Do not serve or taste any that smell 'off' (see below).
How do I know if an oyster has gone "off"? Honestly? Common sense. But here are the details: for both restaurant oysters and those you prepare yourself, the oyster should smell clean and briny. The meat should nestle snugly in the shell, though a little professional loosening is acceptable to the diner if not exactly to the oyster. Both shell and meat should be clean white, with a little pink or gray highlighting being acceptable, beneath a glassy sheen. Any oyster whose meat or liquor looks cloudy, brown, gray, blackish or reddish, or which smells brackish, should be discarded.
So what about those months with the "r" in them? There are too many legends as to where this aphorism came from to identify its true source (my favorite holds that it was introduced by Native Americans, which does not account for the fact that coastal tribes who ate shellfish would have been doing so long before being introduced to the Julian calendar via invasion). The more basic truth is that, wherever it came from, the "month with an r" proverb developed because those months coincide with northern hemisphere summer. During those warmest months, a variety of changes occur in marine environments, everything from red tide to spawning. These phenomena would make food oysters less desireable both aesthetically and hygenically during this time. As you're now committed to eating only commercially grown and harvested oysters provided you're not allergic to them to begin with, the maxim doesn't really apply, as the dangerous or unappealing conditions of the months-without-an-r are premanaged for you by harvesters, processors, shippers, fishmongers, chefs and, presumably, the oysters. That said, though this is a point of debate, oysters are at their best during autumn, winter and early spring.
*Note: though the scientific information in this post was gathered from scientific and medical resources, it is not meant to be the advise or treatment of a medical doctor.