longkyanh/laravel-optivo

Laravel 的 Optivo 邮件客户端

v0.5 2016-02-28 13:30 UTC

This package is not auto-updated.

Last update: 2024-09-20 18:34:03 UTC


README

Optivo 邮件客户端用于 Laravel ( >= v5 )。

使用方法

  • composer require longkyanh/laravel-optivo

  • 依赖注入

use Longkyanh\Mailer\Optivo as Mailer;

class TestEmailController extends Controller
{
    protected $mailer;

    public function __construct(Mailer $mailer)
    {
        $this->mailer = $mailer; // auto resolve by Laravel container
    }

    public function testEmail():Response
    {
        $mailingListName = 'a-test-mailing-list';
        $locale = 'en';
        $recipient = 'nguyentienlong88+1@gmail.com';
        $data = [
            'firstname' => time(),
            'lastname' => time(),
            'age' => time(),
            'message' => time(),            
        ];
        $temp = $this->mailer->send($mailingListName, $locale, $recipient, $data);

        return new Response($temp);
    }
}
  • 使用 OptivoMailer Facade

    • 在 config/app.php 中添加以下行

      Longkyanh\Mailer\OptivoServiceProvider::class,

    • 然后在任何类中使用

      // before any class definition
      use Longkyanh\Mailer\OptivoMailer;
      
      // call send function anywhere you want
      OptivoMailer::send($mailingListName, $locale, $recipient, $data);