Skip to content

SmtpMailer

Viames Marino edited this page Feb 23, 2026 · 1 revision

Pair framework: SmtpMailer

Pair\Services\SmtpMailer is a Mailer implementation based on PHPMailer SMTP transport.

Main methods

  • setConfig(array $config): void
  • checkConfig(): void
  • send(array $recipients, string $subject, string $title, string $text, array $attachments = [], array $ccs = []): void

Required config keys

  • fromAddress
  • fromName
  • smtpHost
  • smtpPort
  • when smtpAuth=true: smtpUsername, smtpPassword

Optional:

  • smtpSecure (ssl/tls)
  • smtpDebug
  • smtpAuth

Implementation example

use Pair\Services\SmtpMailer;

$mailer = new SmtpMailer([
    'fromAddress' => 'noreply@example.com',
    'fromName' => 'Pair App',
    'smtpHost' => 'smtp.example.com',
    'smtpPort' => 587,
    'smtpSecure' => 'tls',
    'smtpAuth' => true,
    'smtpUsername' => 'smtp-user',
    'smtpPassword' => 'smtp-pass',
]);

$mailer->send(
    [['name' => 'John', 'email' => 'john@example.com']],
    'Welcome',
    'Welcome',
    'Thanks for joining.'
);

See also: Mailer, SendMail, AmazonSes.

Clone this wiki locally