I am hosting a webapp on heroku using the free plan. I have also bought a domain name from godaddy.com. My webapp and godaddy are linked through the cloudflare service in order to protect against DOS and so that I can provide a secure connection. I would like to be able to send emails from firstname.lastname@example.org but I don't want to have to buy an expensive email plan on godaddy. Is there any way that I can host my own email server on heroku or something so that I can use my own domain to send emails?
If you try to host your own email server on Heroku you may face various problems (such as high pricing for running additional dynos, a lack of direct and easy SSH access to debug problems and the potential to be on an IP blacklist). Heroku is mainly designed for hosting web applications and not to serve as a mail server. A more comprehensive list of issues with running your own server for mail may be found here.
I built a free and open source solution for this exact situation.
Simply set a few DNS records and you're good to go!
As far as I know Heroku is a web app framework and can't be used as a mail server.
While Heroku doesn't have an email offering that I know of, you are free to use an email host other than Godaddy. Email uses a separate set of DNS records called
MX records. To set up your domain's email, you would typically set the MX records something like:
10 mx1.my-email-host.example 20 mx2.my-email-host.example
Where the two host names are provided by your email hosting company and the number in front is a priority, usually also specified by your email hosting company.
Your cheapest option is to look for a email forwarding service. They would simply forward your email to your already existing email account such as Gmail. You wouldn't get a mailbox at your domain name that would collect mail. You might not be able to easily send email from your domain. Some domain registrars even offer email forwarding for free with domain registration (but not GoDaddy). You can search for "domain email forwarding service" or "domain email forwarding reviews" to find places that will forward your domain email.
If you want more full service mailbox hosting (like Godaddy offers), it generally isn't free. I've seen it for as little as $2 per month per mailbox. Many services are $4 or $6 per month for each mailbox. To compare services and get a good rate search for "hosted email reviews", or "mailbox hosting reviews."
I wouldn't recommend trying to host your own email server at home. Email servers are notoriously hard to secure (just ask Hillary Clinton.) In addition, many ISPs block incoming mail ports as a spam prevention measure. See Why you shouldn’t try to host your own email – GeekWire. However if you can't be dissuaded, it is possible in many cases with enough technical know-how.