SmtpMailer - viames/pair GitHub Wiki

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' => '[email protected]',
    'fromName' => 'Pair App',
    'smtpHost' => 'smtp.example.com',
    'smtpPort' => 587,
    'smtpSecure' => 'tls',
    'smtpAuth' => true,
    'smtpUsername' => 'smtp-user',
    'smtpPassword' => 'smtp-pass',
]);

$mailer->send(
    ['name' => 'John', 'email' => '[email protected]'](/viames/pair/wiki/'name'-=>-'John',-'email'-=>-'[email protected]'),
    'Welcome',
    'Welcome',
    'Thanks for joining.'
);

See also: Mailer, SendMail, AmazonSes.