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 Kam Low, Co-founder · Updated

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 reserves a protected Nitrosend brand subdomain without consuming provider resources. Preparing it creates DNS and provider infrastructure on demand; the first live send waits for readiness and explicit selection, with a 50-recipient rolling-24-hour commercial cap on Free. 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 we 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

Here is the deeper point, honestly. The fix for "how do I send email in PHP" is not a better library, it is not installing one at all. Describe the send to Claude, Cursor, or Codex and our MCP server drafts and sends it on the same account and key, no composer require and no PHPMailer object to configure.

The one-POST version: send email with PHP. Why the mail() starting point fails: PHP mail via SMTP. The port you pick matters less than the records behind it, so read SMTP ports alongside SPF, DKIM and DMARC authentication.

FAQ

How do I install PHPMailer with Composer?

composer require phpmailer/phpmailer, then configure an SMTP host, port, and credentials. It's the best SMTP client PHP has; it just doesn't touch deliverability, which lives in domain authentication and sender reputation.

PHPMailer or an email API?

PHPMailer when a legacy system requires SMTP. An email API otherwise: less config, no credentials in code, and delivery events built in.

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.

Daily allowances depend on your plan and sender standing. Strong list, domain and delivery evidence can raise standing, including on day one. Trusted receives the full plan allowance; available email credits, safety checks and delivery pacing still apply.

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

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