This adapter is wrapper around popular PHPMailer. Koldy framework doesn't ship PHPMailer so you have to install it by yourself, otherwise you won't be able to use it.
We recommend this adapter when you want to send email using some external SMTP server.
To install PHPMailer, use Composer. There are two ways how to install:
- Add
"phpmailer/phpmailer": "~6.0"
torequire
section incomposer.json
located in root of your project and then runphp composer.phar update
- Or run
php composer.phar require phpmailer/phpmailer
in the root of your project
This is example of configuration how to send an email over remote SMTP server.
return [
'phpmailer' => [
'enabled' => true,
'adapter_class' => '\Koldy\Mail\Adapter\PHPMailer',
'options' => [
'host' => 'mail.example.com',
'port' => 587,
'username' => 'someUsername',
'password' => 'somePassword',
'type' => 'smtp'
]
]
];
You can set additional adjust
property within options
which is a function that gets PHPMailer instance as first
parameter and this is where you can modify instance properties. PHPMailer has many options and you can use those options
here.
Very common case is to use GMail as SMTP provider. Here's configuration example that works for GMail and it's using
adjust
:
return [
'phpmailer' => [
'enabled' => true,
'adapter_class' => '\Koldy\Mail\Adapter\PHPMailer',
'options' => [
'host' => 'smtp.gmail.com',
'port' => 465,
'username' => 'your.address@gmail.com',
'password' => 'yourAppPassword',
'type' => 'smtp',
'adjust' => function ($mailer) {
/** @var $mailer \PHPMailer\PHPMailer\PHPMailer */
$mailer->SMTPSecure = 'ssl';
}
]
]
];
You can obtain your own app password on Google Accounts.