Home/Email API/PHPMailer via Composer

PHPMailer via Composer

composer require phpmailer/phpmailer takes ten seconds. It gives you a clean SMTP client, and precisely nothing that decides whether the email lands.

Verified By George Hartley, Co-founder · Updated July 20, 2026

The install and the honest setup

PHPMailer is the right library if PHP must speak SMTP: actively maintained, handles encoding and attachments, escapes the injection traps mail() invites.

Terminal + PHPcomposer
composer require phpmailer/phpmailer

$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host = "smtp.example.com";  $mail->Port = 587;
$mail->SMTPAuth = true;
$mail->Username = "user";  $mail->Password = "pass";
$mail->setFrom("[email protected]");  $mail->addAddress("[email protected]");
$mail->Subject = "Welcome";  $mail->msgHTML("<p>You're in.</p>");
$mail->send();

What the install doesn't buy you

Deliverability needs more than that: an authenticated domain with SPF, DKIM, and DMARC aligned, warmed sending infrastructure, bounce and complaint handling, and a suppression list. PHPMailer transports; it cannot do any of those.

The comparison worth making is not PHPMailer vs mail(). It's ten lines of SMTP config and credentials vs one cURL POST with a bearer token, where the platform owns the landing.

We know exactly how heavy the real setup feels, because we measured ours: verifying a technical sending domain used to mean adding five DNS records, with four more recommended. Asking a developer to do that during onboarding is a non-starter, so we flipped the default. A fresh account sends from a shared sandbox domain immediately, capped at 50 sandbox emails a month, and the DNS ceremony happens later, once the integration already works. Composer gives you the library in ten seconds. Your first send deserves the same respect for your time.

Same logic applies to the email itself. Installing a library doesn't design the message any more than it delivers it, which is why I keep a dedicated email design skill on GitHub that does better anti-slop design than any default template. The tooling should raise the craft, not just move the bytes.

Full parameters and responses live in the REST API docs and the API reference.

The trap
Gmail app password
abcd efgh ijkl mnop
✕ 500 emails/day cap
✕ breaks when 2FA settings change
✕ a full-inbox credential in your code
The fix
POST /v1/messages
Authorization: Bearer ns_live_…
✓ scoped API key, revoke anytime
✓ 8,000 free sends, no daily cliff
✓ delivery events you can act on

Go deeper

The one-POST version: send email with PHP. Why the mail() starting point fails: PHP mail via SMTP.

First send in thirty seconds.

Simple pricing. Unlimited contacts.

Every plan includes full stack emailing: Flows, Newsletter Campaigns and Transactional Email, plus our NitroWheel LLM and all agent integrations (Claude, ChatGPT, Codex, Cursor and others). Pay for what you send, not who you store.

Free
$0
forever
  • Emails 8,000then 500/mo
  • Email types Transactional & Marketing
  • AI actions 20/mo
  • Contacts Free & Unlimited
  • Brands 1
  • Seats 1
Start free
Ultra
$100
per month
  • Emails 125,000/month
  • AI actions 5,000/mo
  • Brands 5
  • Seats 10 · Domains 3
  • Frontier AI Included
  • Dedicated IP Available
Get started
Enterprise
$300
per month
  • AI actions Unlimited
  • Unlimited brands & domains Included
  • SSO / SAML Included
  • 99.9% SLA Included
Get started

Free forever. No credit card required. See full comparison →