Let's say I have domain XYZ.com, which points to a hosting service. Can I configure that to redirect all incoming emails to my username@IPaddress? I have no problem setting up port forwarding of course.
- Accept/forward incoming connections on port 25 to your mail server.
- Make your domain's MX record point to your home IP address.
- Install and configure a MTA (message transfer agent) like Postfix.
How about outgoing emails? Can I send them directly from my home IP address, contacting a remote mail server for delivery?
I'm not sure if I understood this part well. You can either send them directly from your IP address or through a remote mail server.
In theory, sending directly will work with the MTA. In practice, it's quite possible that your ISP is blocking outgoing connections on port 25 (to prevent spam) or that your IP os on some blacklist (check here).
Sending emails using a remote server can be done by the MTA or any email client.