bronanza/laravel-emailer 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bronanza/laravel-emailer

Composer 安装命令:

composer require bronanza/laravel-emailer

包简介

This package provides abstraction for sending email

README 文档

README

#laravel-emailer

laravel-emailer add a way to

Installation

  1. To install laravel-ongkir, add the following line to composer.json. Then run composer update:
"bronanza/laravel-emailer": "dev-master"
  1. Add the following code to the AppServiceProvider.php
public function register()
{
    $this->app->singleton(
        'Bronanza\Emailer\Contracts\Emailer',
        'Bronanza\Emailer\LaravelEmailer'
    );
}

Usage

  1. Make a class that contain the confifuration for the email
<?php
namespace App\Http\Controllers;

use Illuminate\Mail\Message;
use Bronanza\Emailer\Contracts\Email;
use App\User;

class UserEmail implements Email
{
    /**
     * Show the profile for the given user.
     *
     * @param  int  $id
     * @return Response
     */

    public function __construct(User $user)
    {
        $this->user = $user;
    }

    // View that will be used for the email
    public function template()
    {
        return 'email.email-test';
    }

    // Data that will be used in the view
    public function templateData()
    {
        return [
            'user' => $this->user,
        ];
    }

    public function setup()
    {
        return function (Message $message) {
            $customerSupport = [
                'email' => 'apeng@example.com',
                'name' => 'apeng'
            ];

            $subject = 'Test Sending Email';

            return $message
                ->from($customerSupport['email'], $customerSupport['name'])
                ->to($this->user->email, $this->user->first_name)
                ->bcc($customerSupport['email'])
                ->subject($subject);
        };
    }
}
<?php

namespace App\Http\Controllers;

use App;
use App\User;
use App\Http\Controllers\Controller;
use Bronanza\Emailer\Contracts\Emailer;
use App\Http\Http\Controller\UserEmail;

class SendEmail
{

    protected $emailer;
    /** 
    *    instantite the emailer interface
    **/
    public function __construct(Emailer $emailer)
    {
        $this->emailer = $emailer;
    }


    public function index()
    {
        // Create a new Email object that contains the configuration
        $email = App::make('App\Http\Controllers\UserEmail');
        // Send the email
        $this->emailer->send($email);
    }
}

统计信息

  • 总下载量: 30
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-01-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固