项目作者: bakaphp

项目描述 :
PhalconPHP email wrapper for Swiftmailer for sending emails with Queue
高级语言: PHP
项目地址: git://github.com/bakaphp/mail.git
创建时间: 2018-02-22T00:17:38Z
项目社区:https://github.com/bakaphp/mail

开源协议:MIT License

下载


Phalcon\Mailer

Baka email wrapper for Swiftmailer with queue

Configure

SMTP

  1. 'email' => [
  2. 'driver' => 'smtp',
  3. 'host' => getenv('EMAIL_HOST'),
  4. 'port' => getenv('EMAIL_PORT'),
  5. 'username' => getenv('EMAIL_USER'),
  6. 'password' => getenv('EMAIL_PASS'),
  7. 'from' => [
  8. 'email' => 'noreply@domain.do',
  9. 'name' => 'YOUR FROM NAME',
  10. ],
  11. 'debug' => [
  12. 'from' => [
  13. 'email' => 'noreply@domain.do',
  14. 'name' => 'YOUR FROM NAME',
  15. ],
  16. ],
  17. ];

Setup DI

createMessage()

  1. $di->set('mail', function () use ($config, $di) {
  2. //setup
  3. $mailer = new \Baka\Mail\Manager($config->email->toArray());
  4. return $mailer->createMessage();
  5. });

Sending a normal email()

  1. $this->mail
  2. ->to('info@domain.do')
  3. ->subject('Test Normal Email queue')
  4. ->content('normal email send via queue')
  5. ->send();
  6. ];

Sending a template normal email()

  1. $this->mail
  2. ->to('info@domain.dom')
  3. ->subject('Test Template Email queue')
  4. ->params(['name' => 'test'])
  5. ->template('email.volt') //you can also use template() default template is email.volt
  6. ->send();
  7. ];

Sending a normal email instantly, without queue()

  1. $this->mail
  2. ->to('info@domain.do')
  3. ->subject('Test Normal Email now')
  4. ->content('send normal email now')
  5. ->sendNow();
  6. ];

Events

  • mailer:beforeCreateMessage
  • mailer:afterCreateMessage
  • mailer:beforeSend
  • mailer:afterSend
  • mailer:beforeAttachFile
  • mailer:afterAttachFile

Setup CLI

  1. use Phalcon\Cli\Task;
  2. /**
  3. * Class LsTask
  4. * @description('List directory content', 'The content will be displayed in the standard output')
  5. */
  6. class MainTask extends Task
  7. {
  8. use Baka\Mail\JobTrait;
  9. }

Running CLI

php app.php main mailqueue email_queue