The web server you use has, in essence, only one mail transport protocol. That is SMTP (Simple Mail Transfer Protocol).
Sendmail and Qmail are applications with SMTP email sending capabilities and configuration. Sendmail is now pervasive and widely used. There are still a few servers with Qmail installed – fortunately for developers the coding for Qmail is now the same as Sendmail (even the php.ini directives are identical). For the purpose of this article, Sendmail will refer to both Sendmail and Qmail.
Note that SMTP and Sendmail send emails only. They do not receive or store emails.
IMAP receives emails. And acts as an email filing cabinet with a master inbox, and folders for Drafts, Sent, Archive, Spam, Junk, and Trash (as typical defaults). IMAP also has the ability to send emails (PHP function imap_mail) ... as a wrapper to Sendmail.
The last email transport is the PHP mail() function. This, like imap_mail(), is a wrapper for Sendmail.
PHP mail() and imap_mail() are easy to use for simple email messages ... by simple, I mean limited recipients, plain text (or basic HTML), and no attachments. Increase the complexity with both plain text and HTML or simply adding an attachment and both mail(0 and imap_mail() become nightmares to code.
Sendmail and SMTP are easier to code, but both more difficult to track and deal with error handling.
I will also point out: PHP mail(), imap_mail(), and Sendmail are all used "unauthenticated". SMTP in its most basic use is also "unauthenticated". SMTP is typically used in "authenticated" mode.
My own personal preferences, in order:
- SMTP ... SMTP is designed to send emails with a robust set of functions to track and monitor the progress of the operations. SMTP can easily handle the needs of large mailing lists just as easily as single individual emails.
- Sendmail is also designed to send mails. At one time, SMTP typically ran on a separate server. Most providers added Sendmail (or similar functionality) so their users could send small quantities of emails. Sendmail, et al, require opening sockets to stream the transport.
- Mail() and imap_mail() are wrappers to Sendmail ... much more basic in coding and concept. The wrapper handles all the transport (instead of the developer.