SMTP TCP Socket Emailing

SMTP Mailing without Vendor Bloat

To preserve absolute zero-dependency performance, Zero CMS rejects massive outbound mailer libraries (such as PHPMailer or curl-based APIs) in favor of a native TCP socket emailing handshake nested inside src/Support/Emailer.php.

The SMTP Raw Socket Dialogue

The Emailer opens a raw network socket connection to the target mail server (e.g. Mailpit on port 1025) and handles the SMTP dialogue manually, reading server response codes strictly:

$socket = fsockopen('mailpit', 1025, $errno, $errstr, 5);

// Handshake steps:
fputs($socket, "EHLO newsite.zero\r\
");
fputs($socket, "MAIL FROM: <sender@zero.org>\r\
");
fputs($socket, "RCPT TO: <buyer@zero.org>\r\
");
fputs($socket, "DATA\r\
");

// Send headers and raw body envelope...
fputs($socket, ".\r\
"); // Dot on a single line signals SMTP data completion
fputs($socket, "QUIT\r\
");

MIME-Compliant Envelope Wrapping

The custom TCP socket mailer wraps the payload inside strict, multi-boundary MIME headers to support clean HTML templates, attachments, and UTF-8 encoding natively offline.