MarkR wrote:The above is daft. Don't write your own SMTP implementation (PHP has one built in!), and don't use SMTP if there is a local MTA available (e.g. if sendmail is working).
A local MTA is pretty much essential, as this is the only way which mail will get queued correctly if the upstream server (smart host or whatever) is down for any reason.
Neither PHP's SMTP implementation, nor the above piece of code, have any provision for queueing and retrying in the event of a server failure.
Mark
I realize i'm new to the forums but what you say is not 100% accurate, i think its a terminology issue.
By MTA i'm assuming you are talking about mail transport agent which is prety much any SMTP (simple mail transfer protocol NOT send mail to people as some people call it). Sendmail, Postfix, Qmail, IMail and many others all include SMTP servers and are considered a MTA.
What the script does is connect to port 25 of the specified server (usually would be the domain or server that the script is hosted at). Port 25 is by default the SMTP port for MTA's and sends the RFC commands in correct order (unless i missed something) to send a message.
the built in PHP command and script above in my mind is more of a Mail Transport Client. Neither the mail() or script above have queing, nor do they really need it. Queuing is handled by the MTA such as sendmail,postfix,imail,qmail, etc.... This is a non issue. If you want queing (like an Outbox) use Thunderbird or Eudora Mail Clients.
Any mail you send with any client does what the above script does ( in essense ) at some point regardless of what mail client you use only using sockets you have complete control over what is being sent and recieved.
use what works or what you like best, mail, the script above, PHPMailer what have you, dosn't matter to me as long as you do it for the right reasons, it works and does not leave people open to spam 🙂