I am relatively new to arena of emails. Just drilling out tutorial by tutorial about email internals. My requirement is I need to send emails and receive emails from my webhost. For this to happen, I need an smtp server(daemon) running right? I recently studied about MTAs, which are responsible for transferring emails from one host to the other. So this smtp server(daemon) acts as an MTA. And I also studied sendmail is an MTA, which boils down to sendmail runs a smtp daemon in the background. Right?
You need to run daemon to receive emails and to resend emails if they failed to be sent for some reason.
To send them, you just invoke sendmail
which will connect to the destination's sendmail
(which, of course, runs as a daemon), send you mail and exit.
If you sending this from a website, you may use mail functions of your scripting language, because spawning a process is quite costly thing under a heavy load.
It's probably fairer to say that sendmail is an SMTP daemon than to say it runs one, since sendmail is pretty monolithic. But basically you have it right - in order to receive email, you need an MTA listening on port 25 when an incoming connection comes. There are many choices for an MTA. I prefer postfix because it's not monolithic, it has a very easy to read config file, and it has a good security model. Other good choices are exim and qmail.
For outgoing mail, you need a program that can figure out where the mail is supposed to go, and make a connection to that receiver's port 25. Once again, just about any MTA will do that for you, but some programs that want to send mail will attempt to do it directly instead of invoking the local MTA. The problem with that is that they then have to duplicate all the things MTAs give you, such as knowing how to fall back and retry when the mail receiver can't be reached.