Monday, 8 August 2016

email - PHP What is the reason of usages between mail() and SMTP?










In PHP, as long as i can send emails by using very simple mail() native function,




  • what is the good reason to use smtp?



Note: Please, I do not have enough knowledge in mail systems. So maybe i need a brief explanation about major differences in why using these two systems.


Answer



mail() IS using SMTP in the background. it does not deliver the mail for you. When you call mail() PHP is simply handing the email over to your local system's SMTP system (sendmail, postfix, exim, etc...). Once the handoff is complete, PHP is out of the email game. It's up to the SMTP system to actually start the delivery process.



That being said, mail() is useful for quick and dirty simple emails. but anything moderately complicated (multiple recipients, mixed text/html emails, attachments, etc...) become highly tedious/complicated with just mail(), but quite simple when using a better smtp library, like PHPMailer or Swiftmailer.


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...