Mechanical switches are less complicated to implement and cheaper than optical endstops because they do not require a circuit board and only use 2 wires for connecting the switch. Pull up and down resistors can be put close to the main board. You can use contact switches and contact-less (usually magnetically actuated) mechanical switches. Contact-less magnetic switches are called reed switches. They are proximity switches that close (or switch over) if a magnet comes close enough (usually 1mm or less) and open if the magnet moves away. Reed switches are used as sensors in home alarm systems to detect open windows and doors.
How to wire a mechanical switch to replace an optical endstop.
Where to get it?
|Link||From||Size||Lever Type||Approx. Cost||Additional notes|
|buy it from geeetech ebay||China||20mm||Simulated Roller Lever||$5ea||-|
|3D Maker World||US||20mm||Simulated Roller Lever||$1.75 ea||-|
|Charlie's 3D Technologies||Belgium||20 x 6.5 x 13.5 mm||Hooked Lever||€1,61||-|
|Think3D-Print3D eMAKERshop||UK||20mm||Straight||£2.5/3||also sold with pull up resistors (see the other items)|
| Louisliu2009 ebay 
|$32/100||can take a long time to arrive|
|Makemendel||India||20mm?||Roller Bended||$1 USD||Also available with 3 pin connector soldered.|
Good reasons to use a mechanical switch
- The flags wont bend.
- Less Expensive in most cases.
- No need for opto pcb.
- Simple switches can be used on x and y axis.
- You could even make your own contact switch from a few pieces of metal.
- A simple way to put in max endstops.
- You get to solder stuff.
- Contactless (reed switch)
Limitations of mechanical switches
- Switches have a limited number of on/off cycles. However, most purpose built micro-switches are rated for well over 10,000 cycles and will last years.
- Needs new way to mount switch, which will depend on the switch type.
- The repeatability of the switch is very important for the z axis, and not all switches will work.
Opto Endstop v1.0, v2.1 and Tech Zone Remix
Note the Tech Zone Remix Endstops are working the opposite way (normally closed) as the insctructions below, so you need to change either your firmware or the wiring of the switch to compensate.
Copied from DarwinOptoEndstop#Interface
|+5||This is the pin to supply +5 volts on.|
|S||This is the signal pin. It will output high (+5) if it is triggered, or low (0v) if it is clear|
|G||This is the ground pin.|
You want a normally closed (NC) switch. Meaning you need a switch which connects two poles when not triggered. (A single pole double throw (SPDT) switch will work, if you wire up to the NC side of the switch -- ignore the NO pin). Read more at wikipedia.
"what happens if it's unplugged or my pet rabbit chews through the cable?" Design it such that when it's unplugged, it registers as "at the end" rather than "keep going". 
For the z axis, high resolution (aka short trigger distance) and high repeatability is needed.
The x and y axis resolution is not that important, unless you home the machine during a print. But you are of course encouraged to use a high quality switch if you can, as it certainly won't hurt.
Where to buy switches
Eagle 5.10.0 light schematic: File:Mechanical endstop wiring schematic.sch
When the switch is off (like in the schematic above), it connects signal to ground. When the switch is triggered, the ground connection is cut and the signal is connected to 5v through the pull up resistor.
Make sure you keep the wires away from the motor leads and / or used screened cable as it is easy to pick up enough noise to get false triggering. 
Note: if you use Teacup or Sprinter firmware, resistor R1 and the connection to 5V are obsolete. The ATmega has internal pullup resistors, which can be turned on. That's done with the USE_INTERNAL_PULLUPS flag in config.h (Teacup) or ENDSTOPPULLUPS in configuration.h (Sprinter).
If you want an indicator, you can hook up a LED (and a matching resistor).
You need a way to mount the switch on the printer. Feel free to share your solutions and designs here. Modular design encouraged to fit different switches.
The endstop holder from Prusa Mendel works fine. Take care to solder the wires pointing up, to place the holder as far out as possible, and this maximize the build space.
Needs to sit very securely, but still be easy adjustable in small increments. The endstop holder from Prusa Mendel works fine. To simplify design, I suggest a very solid mount even if it is very hard to adjust. It is often easier to set the location of the endstop in firmware than it is to try and move the actual switch around .01 mm at a time!