PingMail Documentation

PingMail is a lightweight, zero-dependency SMTP library for PHP. It allows you to send emails via standard SMTP servers without the bloat of PHPMailer or SwiftMailer.

Fast

Uses raw TCP sockets.

Tiny

Only ~2KB file size.

Secure

TLS 1.2/1.3 Support.


Installation

Since PingMail is a single-file library, installation is as simple as downloading the file and requiring it in your PHP script.

wget https://pingmail.softmaji.in/PingMail.php

Or simply right-click the "Download" button on this site and save it to your project folder.

Sending Your First Email

Here is a complete example of how to connect to an SMTP server (like Gmail) and send an HTML email.

require_once 'PingMail.php'; use SoftMaji\PingMail\PingMail; // 1. Setup Configuration $host = 'smtp.gmail.com'; $port = 587; $user = 'your-email@gmail.com'; $pass = 'your-app-password'; // 2. Initialize Engine $mail = new PingMail($host, $port, $user, $pass, 'tls'); try { // 3. Send Message $mail->send( 'recipient@example.com', // To 'sender@example.com', // From 'Subject Line', // Subject '<h1>Hello World</h1>' // Body (HTML) ); echo "Email sent successfully!"; } catch (Exception $e) { echo "Error: " . $e->getMessage(); }

Debugging Connections

If you encounter issues (like a white screen or connection timeout), you can retrieve the raw transaction log to see exactly what the server responded with.

catch (Exception $e) { echo "Error: " . $e->getMessage(); // Print the raw logs print_r($mail->getDebugLog()); }