← All libraries

SugarPost

SugarPost

Email sending — SMTP, API transports, attachments

port of charmbracelet/skate emailmailsmtpattachment

Email builder and sender. SMTP transport, Resend API transport, attachment support, HTML + plain-text multipart, and a fluent interface.

Install

composer require sugarcraft/sugar-post

Quickstart

use SugarCraft\Post\{Email, SmtpTransport, Attachment};

$email = (new Email())
    ->from('noreply@example.com')
    ->to('user@example.com')
    ->subject('Deployment complete')
    ->text('Your app was deployed successfully.')
    ->html('<p>Your app was deployed <strong>successfully</strong>.</p>')
    ->attach(Attachment::fromPath('/tmp/build.zip', 'build.zip'));

$transport = new SmtpTransport('smtp.example.com', 587);
$transport->send($email);

What's in the box

SMTP transportTCP connection with TLS, auth (plain/login), and batching.
Resend transportAPI-based sending via Resend.com — no SMTP needed.
AttachmentsLocal files, memory content, custom MIME types.
HTML + TextMultipart/alternative email bodies.

Source & demos

Try the quickstart →

API

ClassMethodDescription
Emailnew()Create email
Emailfrom(addr), to(addr), subject(text)Set email fields
Emailtext(body), html(body)Set body content
Emailattach(attachment)Add attachment
SmtpTransportnew(host, port)Create SMTP transport
SmtpTransportsend(email)Send email
AttachmentfromPath(path, name)Create from file

Demos.

VHS-recorded GIFs of every example shipped with the library. Regenerated automatically on every push that touches the source.

Email DTOs + transports

Email DTOs + transports

Plain + multipart Email values, transport surface listed.