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): voidcheckConfig(): voidsend(array $recipients, string $subject, string $title, string $text, array $attachments = [], array $ccs = []): void
Required config keys
fromAddressfromNamesmtpHostsmtpPort- when
smtpAuth=true:smtpUsername,smtpPassword
Optional:
smtpSecure(ssl/tls)smtpDebugsmtpAuth
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.'
);