eusend
SMTP

PHP (PHPMailer) SMTP

Send email from plain PHP through eusend using PHPMailer over SMTP — implicit TLS on port 465, DKIM-signed and tracked.

For a PHP app without a framework, PHPMailer is the standard SMTP client. Point it at eusend and your mail is DKIM-signed, tracked, and subject to the same limits as the HTTP API.

Install

composer require phpmailer/phpmailer

Send an email

send.php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'vendor/autoload.php';

$mail = new PHPMailer(true);

try {
    $mail->isSMTP();
    $mail->Host       = 'smtp.eusend.dev';
    $mail->SMTPAuth   = true;
    $mail->Username   = 'eusend';                       // the literal string "eusend"
    $mail->Password   = getenv('EUSEND_API_KEY');       // eu_live_…
    $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;    // implicit TLS
    $mail->Port       = 465;

    // From must be on a domain verified in eusend
    $mail->setFrom('no-reply@yourdomain.com', 'Acme');
    $mail->addAddress('alice@example.com');

    $mail->isHTML(true);
    $mail->Subject = 'Your order has shipped';
    $mail->Body    = '<p>Order #1234 is on its way.</p>';
    $mail->AltBody = 'Order #1234 is on its way.';

    $mail->send();
} catch (Exception $e) {
    echo "Send failed: {$mail->ErrorInfo}";
}
⚠

Use ENCRYPTION_SMTPS with port 465 (implicit TLS), not ENCRYPTION_STARTTLS. STARTTLS on 587 is not supported.

Connection reference

PropertyValue
Hostsmtp.eusend.dev
Port465
SMTPSecurePHPMailer::ENCRYPTION_SMTPS
Usernameeusend
Passwordyour eusend API key (eu_live_…)
setFrom()an address on a verified domain

Use an eu_test_ key while developing — sends are tracked but not delivered. See the SMTP overview for limits and status codes.

Troubleshooting

SymptomCause and fix
SMTP Error: Could not authenticate.Read the response text. Invalid credentials means the username is not the literal eusend or the API key is wrong. A message naming a domain means the From address is on a domain you have not verified. Set $mail->SMTPDebug = SMTP::DEBUG_SERVER; to print the server's response.
SMTP Error: Could not connect to SMTP host. or SMTP connect() failedThe connection is not using implicit TLS on 465, or your host blocks the port. Set SMTPSecure = PHPMailer::ENCRYPTION_SMTPS and Port = 465. eusend does not accept SMTP on 587 or 25.
The script hangs, then times outSMTPSecure is PHPMailer::ENCRYPTION_STARTTLS or empty while Port is 465, so PHPMailer waits for a plaintext greeting. Use ENCRYPTION_SMTPS.
535 Too many failed attempts or 421 Connection rejectedRepeated failed logins block your IP address for up to an hour. Fix the credentials, then wait before retrying.
Password is emptygetenv('EUSEND_API_KEY') returned false — the variable is not set for the PHP process (web server and CLI often have different environments).
Send rejected with 550Every recipient is on your suppression list, or the message failed validation. $mail->ErrorInfo carries the reason.

See the SMTP overview for the full status-code table.