Immunities are the best defense against a form of attack. Being immune means that you are not at risk of whatever it is you are immune to, period. So, here are a bunch of ways to become immune to a bunch of things.
This does not include every type of monster with immunity to something. This is mostly for classes, feats, items, spells, and other more generally accessible options. Races described as player races, along with types, and subtypes, are included. Abilities common to a general category of creatures (such as the spell immunity of golems) may be included, but individual monster entries are not.
All phantasm's are mind-affecting. Most immunities to mind-affecting effects specifically call out phantasm immunity as part of the more general mind-affecting immunity as well.
This category refers to the general spell immunity that functions as infinite spell resistance and thus does not apply against spells that ignore spell resistance.
I started to look into this once. I got overwhelmed though. Probably, I took too broad a definition of "immunity." For example, I figured the ability to breathe water should count as immunity to drowning. Here's what I can find of my notes.
Ring of freedom of movement, 40,000 gp, Dungeon Master's Guide 232
Paralysis, grapple, effects that impede movement
Hathran mask of true seeing, 75,000 gp, Unapproachable East 57
Normal and magical darkness, illusions (within 120 feet)
Proof against transmutation, +5 armor special ability, Complete Arcane 142
Transmutation effects that alter form
Soulfire, +4 armor special ability, Book of Exalted Deeds 112
Death spells, magical death effects, energy drain, negative energy effects
Gemstone of heavy fortification, 35,000 gp plus limited wish, Draconomicon 83
Heavy fortification, +5 armor special ability, Dungeon Master's Guide 219
Critical hits, sneak attack
Ring of sustenance, 2,500, Dungeon Master's Guide 233
Clear spindle ioun stone, 4,000 gp, Dungeon Master's Guide 260
Dehydration, starvation
Ring of mind shielding, 8,000 gp, Dungeon Master's Guide 232
Detect thoughts, discern lies, attempts to discern alignment
Necklace of adaptation, 9,000 gp, Dungeon Master's Guide 263
Iridescent spindle ioun stone, 18,000 gp, Dungeon Master's Guide 260
Drowning, suffocation
Scarab of invulerability, 40,000 gp, Magic Item Compendium 132
Damage, ability damage (1 round per day)
Talisman of undying fortitude, 8,000 gp, Magic Item Compendium 188
Poison, sleep effects, paralysis, stunning, disease, death effects, critical hits, nonlethal damage, physical ability damage, ability drain, energy drain, fatigue, exhaustion, death from massive damage, any effect that requires a fortitude save, drowning, suffocation (6 rounds per day)
Choker of life protection, 14,000 gp, Magic Item Compendium 216
negative levels (3 levels per day)
Scarab of protection, 38,000 gp, Dungeon Master's Guide 266
Energy drain, death effects, negative energy effects (12 attacks)
Heart of steel, 9,000 gp warforged graft (2 hp, half benefit from healing magic), Faiths of Eberron 157
Disease, paralysis, poison
Heavy legs, 6,000 gp warforged graft (2 hp, -2 swim checks), Faiths of Eberron 158
Fatigue (exhaustion becomes fatigue)
Wakeful mind, 14,000 gp warforged graft (2 hp, -2 knowledge checks), Faiths of Eberron 158
Sleep effects, stunning
Banner of the storms eye, 15,000 gp, Explorer's Handbook 155
Confusions, stunning (removed if from supernatural or spell-like source); fear (suppressed, not dispelled)
Blindfold of true darkness, 9,000 gp, Magic Item Compendium 75
Gaze attacks, spells and effects that rely on sight
Sundark goggles, 10 gp, Races of the Dragon 123
Light blindness
Spellblade, +1 weapon special ability, Magic of Faerun 141
Selected spell (targeted/non-area spell only)
Ring of freedom of movement, 40,000 gp, Dungeon Master's Guide 232
Paralysis, grapple, effects that impede movement
Hathran mask of true seeing, 75,000 gp, Unapproachable East 57
Normal and magical darkness, illusions (within 120 feet)
Proof against transmutation, +5 armor special ability, Complete Arcane 142
Transmutation effects that alter form
Soulfire, +4 armor special ability, Book of Exalted Deeds 112
Death spells, magical death effects, energy drain, negative energy effects
Gemstone of heavy fortification, 35,000 gp plus limited wish, Draconomicon 83
Heavy fortification, +5 armor special ability, Dungeon Master's Guide 219
Critical hits, sneak attack
Ring of sustenance, 2,500, Dungeon Master's Guide 233
Clear spindle ioun stone, 4,000 gp, Dungeon Master's Guide 260
Dehydration, starvation
Ring of mind shielding, 8,000 gp, Dungeon Master's Guide 232
Detect thoughts, discern lies, attempts to discern alignment
Necklace of adaptation, 9,000 gp, Dungeon Master's Guide 263
Iridescent spindle ioun stone, 18,000 gp, Dungeon Master's Guide 260
Drowning, suffocation
Scarab of invulerability, 40,000 gp, Magic Item Compendium 132
Damage, ability damage (1 round per day)
Talisman of undying fortitude, 8,000 gp, Magic Item Compendium 188
Poison, sleep effects, paralysis, stunning, disease, death effects, critical hits, nonlethal damage, physical ability damage, ability drain, energy drain, fatigue, exhaustion, death from massive damage, any effect that requires a fortitude save, drowning, suffocation (6 rounds per day)
Choker of life protection, 14,000 gp, Magic Item Compendium 216
negative levels (3 levels per day)
Scarab of protection, 38,000 gp, Dungeon Master's Guide 266
Energy drain, death effects, negative energy effects (12 attacks)
Heart of steel, 9,000 gp warforged graft (2 hp, half benefit from healing magic), Faiths of Eberron 157
Disease, paralysis, poison
Heavy legs, 6,000 gp warforged graft (2 hp, -2 swim checks), Faiths of Eberron 158
Fatigue (exhaustion becomes fatigue)
Wakeful mind, 14,000 gp warforged graft (2 hp, -2 knowledge checks), Faiths of Eberron 158
Sleep effects, stunning
Banner of the storms eye, 15,000 gp, Explorer's Handbook 155
Confusions, stunning (removed if from supernatural or spell-like source); fear (suppressed, not dispelled)
Antimagic Shackles: 132,000 gp, Book of Exalted Deeds 116
Spells, spell-like abilities, supernatural effects (except instantaneous conjurations); incorporeal undead, summoned creatures
Banner of Law: 8,000 gp, Heroes of Battle 133
Possession, mental control
Banner of the Storm's Eye: 15,000 gp, Explorer's Handbook 155
Confusions, stunning (removed if from supernatural or spell-like source); fear (suppressed, not dispelled)
Blindfold of True Darkness: 9,000 gp, Magic Item Compendium 75
Gaze attacks, spells and effects that rely on sight
Braincap: 22,000 gp
Mind blast
Choker of Life Protection: 14,000 gp, Magic Item Compendium 216
negative levels (3 levels per day)
Cowl of Warding: 200,800 gp, Magic of Faerun 156
Emotion/thought reading/influence/detection, mind-affecting effects, divination spells/effects, paralysis, grapple, effects that impede movement
Death Ward: +1 armor special ability, Magic Item Compendium 10
Death effects (death spells, magical death effects, energy drain), negative energy effects (1/day)
Deepdweller: 12,000 gp armor special ability, Magic Item Compendium 10
Drowning, cold water damage, pressure damage
Exalted: +3 armor special ability, Book of Exalted Deeds 112
Possession, mental control
Fortification, Heavy: +5 armor special ability, Dungeon Master's Guide 219
Critical hits, sneak attack
Freedom: +5 armor special ability, Magic Item Compendium 11
Paralysis, grapple, effects that impede movement
Gemstone of Fortification, Heavy: 35,000 gp plus limited wish, Draconomicon 83
Critical hits, sneak attack
Gilled: 6,000 gp armor special ability, Magic Item Compendium 11
Reverse drowning
Hathran Mask of True Seeing: 75,000 gp, Unapproachable East 57
Normal and magical darkness, illusions (within 120 feet)
Helm of Underwater Action: 24,000 gp, Dungeon Master's Guide 259
Drowning, suffocation
Heart of Steel: 9,000 gp warforged graft (2 hp, half benefit from healing magic), Faiths of Eberron 157
Disease, paralysis, poison
Heavy Legs: 6,000 gp warforged graft (2 hp, -2 swim checks), Faiths of Eberron 158
Fatigue (exhaustion becomes fatigue)
Ioun Stone, Clear Spindle: 4,000 gp, Dungeon Master's Guide 260
Dehydration, starvation
Ioun Stone, Iridescent Spindle: 18,000 gp, Dungeon Master's Guide 260
Drowning, suffocation
Necklace of Adaptation: 9,000 gp, Dungeon Master's Guide 263
Drowning, suffocation
Proof Against Transmutation: +5 armor special ability, Complete Arcane 142
Transmutation effects that alter form
Ring of Freedom of Movement: 40,000 gp, Dungeon Master's Guide 232
Paralysis, grapple, effects that impede movement
Ring of Landwalking: 10,000 gp, Stormwrack 130
Reverse drowning
Ring of Mental Fortitude: 110,000 gp, Dungeon Master's Guide II 263
Mind-affecting
Ring of Mind Shielding: 8,000 gp, Dungeon Master's Guide 232
Detect thoughts, discern lies, attempts to discern alignment
Ring of Negative Protection: 72,000 gp, Planar Handbook 81
Negative levels
Ring of Sustenance: 2,500, Dungeon Master's Guide 233
Dehydration, starvation
Scarab of Invulnerability: 40,000 gp, Magic Item Compendium 132
Damage, ability damage (1 round 1/day)
Scarab of Protection: 38,000 gp, Dungeon Master's Guide 266
Energy drain, death effects, negative energy effects (12 attacks)
Shackles of Silence: 12,000gp, Book of Exalted Deeds 116
Sonic or language-based attacks
Shadowy Diadem: 4,400 gp, Dragon Magic 103
Energy drain (10 rounds 3/day)
Soulfire: +4 armor special ability, Book of Exalted Deeds 112
Death spells, magical death effects, energy drain, negative energy effects
Spellblade: +1 weapon special ability, Magic of Faerun 141
Selected spell (targeted/non-area spell only)
Starmantle Cloak: 132,000 gp, Book of Exalted Deeds 116
Nonmagical weapon attacks
Styptic: +1 armor special ability, Magic Item Compendium 15
Bleed effects
Sundark Goggles: 10 gp, Races of the Dragon 123
Light blindness
Talisman of Undying Fortitude: 8,000 gp, Magic Item Compendium 188
Poison, sleep effects, paralysis, stunning, disease, death effects, critical hits, nonlethal damage, physical ability damage, ability drain, energy drain, fatigue, exhaustion, death from massive damage, any effect that requires a fortitude save, drowning, suffocation (3 rounds 2/day)
Third Eye Conceal: 120,000 gp, Magic Item Compendium 141
Emotion/though reading/influence/detection, mind affecting effects, divination spells/effects
Wakeful Mind: 14,000 gp warforged graft (2 hp, -2 knowledge checks), Faiths of Eberron 158
Sleep effects, stunning
Absorbing
Defenders of the Faith 22
Ghostwalk
Amphibious Skin
Lords of Madness 215
Amulet of Incarnum Shielding
Magic of Incarnum 112
Antivenom Ring*
Underdark 71
Aqueous Body
Magic of Eberron 130
Bone Ring
Magic Item Compendium 75
Boots of the Wanderer
Complete Champion 138
Breath of the Waves
Magic of Eberron 130
Crown of Eyes
Fiend Folio 208
Dragonheart Presence
Races of the Dragon 128
Ebon Mask
Dragon Magic 100
Energy Immunity
Magic Item Compendium 11
Glaring Eye
Races of the Dragon 128
Goggles of the Desert
Sandstorm 134
Helm of Righteous War
Complete Champion 139
Legs of the Undying Marcher
Magic of Eberron 129
Periapt of Proof Against Poison
Dungeon Master's Guide 263
Planar Tolerance
Planar Handbook 78
Ring of Elemental Adaptation
Planar Handbook 80
Ring of Positive Protection
Planar Handbook 81
Ring of Water Breathing
Planar Handbook 81
Robe of Ebonsilk:
Complete Divine 100
Robe of Ruhkyon
Unapproachable East 57
Rod of Webspinning
Underdark 72
Sandals of the Vagabond
Complete Champion 142
Spider Boon
Drow of the Underdark 97
Spider Mask
Underdark 75
Sword of Mighty Thews:
Magic Item Compendium 60
Time Buttress
Magic Item Compendium 15
Trackless Boots
Drow of the Underdark 101
Vestments of Steadfast Spellcasting
Planar Handbook 84
Antimagic Shackles: 132,000 gp, Book of Exalted Deeds 116
Spells, spell-like abilities, supernatural effects (except instantaneous conjurations); incorporeal undead, summoned creatures
Banner of Law: 8,000 gp, Heroes of Battle 133
Possession, mental control
Banner of the Storm's Eye: 15,000 gp, Explorer's Handbook 155
Confusions, stunning (removed if from supernatural or spell-like source); fear (suppressed, not dispelled)
Blindfold of True Darkness: 9,000 gp, Magic Item Compendium 75
Gaze attacks, spells and effects that rely on sight
Choker of Life Protection: 14,000 gp, Magic Item Compendium 216
negative levels (3 levels per day)
Cowl of Warding: 200,800 gp, Magic of Faerun 156
Emotion/though reading/influence/detection, mind affecting effects, divination spells/effects, paralysis, grapple, effects that impede movement
Exalted: +3 armor special ability, Book of Exalted Deeds 112
Possession, mental control
Fortification, Heavy: +5 armor special ability, Dungeon Master's Guide 219
Critical hits, sneak attack
Gemstone of Fortification, Heavy: 35,000 gp plus limited wish, Draconomicon 83
Critical hits, sneak attack
Hathran Mask of True Seeing: 75,000 gp, Unapproachable East 57
Normal and magical darkness, illusions (within 120 feet)
Helm of Underwater Action: 24,000 gp, Dungeon Master's Guide 259
Drowning, suffocation
Heart of Steel: 9,000 gp warforged graft (2 hp, half benefit from healing magic), Faiths of Eberron 157
Disease, paralysis, poison
Heavy Legs: 6,000 gp warforged graft (2 hp, -2 swim checks), Faiths of Eberron 158
Fatigue (exhaustion becomes fatigue)
Ioun Stone, Clear Spindle: 4,000 gp, Dungeon Master's Guide 260
Dehydration, starvation
Ioun Stone, Iridescent Spindle: 18,000 gp, Dungeon Master's Guide 260
Drowning, suffocation
Necklace of Adaptation: 9,000 gp, Dungeon Master's Guide 263
Drowning, suffocation
Proof Against Transmutation: +5 armor special ability, Complete Arcane 142
Transmutation effects that alter form
Ring of Freedom of Movement: 40,000 gp, Dungeon Master's Guide 232
Paralysis, grapple, effects that impede movement
Ring of Mind Shielding: 8,000 gp, Dungeon Master's Guide 232
Detect thoughts, discern lies, attempts to discern alignment
Ring of Sustenance: 2,500, Dungeon Master's Guide 233
Dehydration, starvation
Scarab of Invulerability: 40,000 gp, Magic Item Compendium 132
Damage, ability damage (1 round per day)
Scarab of Protection: 38,000 gp, Dungeon Master's Guide 266
Energy drain, death effects, negative energy effects (12 attacks)
Shackles of Silence: 12,000gp, Book of Exalted Deeds 116
Sonic or language-based attacks
Soulfire: +4 armor special ability, Book of Exalted Deeds 112
Death spells, magical death effects, energy drain, negative energy effects
Spellblade: +1 weapon special ability, Magic of Faerun 141
Selected spell (targeted/non-area spell only)
Starmantle Cloak: 132,000 gp, Book of Exalted Deeds 116
Nonmagical weapon attacks
Sundark Goggles: 10 gp, Races of the Dragon 123
Light blindness
Talisman of Undying Fortitude: 8,000 gp, Magic Item Compendium 188
Poison, sleep effects, paralysis, stunning, disease, death effects, critical hits, nonlethal damage, physical ability damage, ability drain, energy drain, fatigue, exhaustion, death from massive damage, any effect that requires a fortitude save, drowning, suffocation (6 rounds per day)
Wakeful Mind: 14,000 gp warforged graft (2 hp, -2 knowledge checks), Faiths of Eberron 158
Sleep effects, stunning
Favor of the martyr, paladin 4, Spell Compendium 89
Nonlethal damage, charm and compulsion effects, pain-based attacks, daze, exhaustion, fatigue, nausea, sickened, stagered, stunned; lessened effect from dying condition
Heroe's feast, bard 6, cleric 6, Player's Handbook
Fear, poison
mind blank
starmantle, Book of Exalted Deeds
silence
antimagic field
death ward
sheltered vitality
delay death
protection from [alignment]
Amorphous Form: assassin 3, sorcerer/wizard 3, Spell Compendium 9
Poison, polymorphing, stunning, flanking, critical hits,