Okay, confused here. I can send emails just fine from my rails app using this service, http://www.mailgun.com/ and their gem.
Responses I've received to Can webmail work without an SMTP server? lead me to believe you can send an email with PHP/Ruby, with no external service.
You can host your own mail server on localhost or another machine in your network. There are Open Source mail servers. These are normally called Mail Transfer Agents (MTA). Some examples are Sendmail and Postfix. There are also others depending on your needs and operating system.
To directly answer your questions: