PHP code example of slowprog / phalcon-mailer
1. Go to this page and download the library: Download slowprog/phalcon-mailer library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
slowprog / phalcon-mailer example snippets
/**
* Register Mailer Service
*/
$this->di['mailer'] = function() {
$service = new MailerService();
return $service->mailer();
};
/**
* Register Mailer Service
*/
$this->di['mailer'] = function() {
$service = new MailerService([
'driver' => 'smtp', // mail, sendmail, smtp
'host' => 'smtp.email.com',
'port' => 587,
'from' => [
'email' => '[email protected] ',
'name' => 'My Cool Company',
],
'encryption' => 'tls',
'username' => '[email protected] ',
'password' => 'some-strong-password',
'sendmail' => '/usr/sbin/sendmail -bs',
// Путь используемый для поиска шаблонов писем
'viewsDir' => __DIR__ . '/../app/views/', // optional
]);
return $service->mailer();
};
$this->mailer->sendView('emails/xxx', [
'test' => 'test' // Переменные для передачи в шаблон
], function($message) {
$message->to('[email protected] ');
$message->subject('Test Email');
});
return new \Phalcon\Config([
'mail' => [
'driver' => 'smtp', // mail, sendmail, smtp
'host' => 'smtp.email.com',
'port' => 587,
'from' => [
'email' => '[email protected] ',
'name' => 'My Cool Company'
],
'encryption' => 'tls',
'username' => '[email protected] ',
'password' => 'some-strong-password',
'sendmail' => '/usr/sbin/sendmail -bs',
// Путь используемый для поиска шаблонов писем
'viewsDir' => __DIR__ . '/../app/views/', // optional
],
]);
use Phalcon\Queue\Beanstalk;
$this->di['queue'] = function () {
$queue = new Beanstalk();
$queue->connect(); // ?
return $queue;
};
$this->mailer->queueView('emails/xxx', [
'test' => 'test' // Переменные для передачи в шаблон
], function($message) {
$message->to('[email protected] ');
$message->subject('Test Email');
});