なんか書くぞ

web系だと思う

laravelのmailer

laravelでメール送るメモ。

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class MarkyMail extends Mailable
{
    use Queueable, SerializesModels;

    var $mailVars;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($maiVars)
    {
        $this->mailVars = $maiVars;
    }

    /**
     * メール送信するぞ
     *
     * @return $this
     */
    public function build()
    {
        $this
            ->view($this->mailVars["mailForm"], $this->mailVars["attr"])
            ->subject($this->mailVars['subject'])
            ->to($this->mailVars['toAddress'], $this->mailVars['name'])
            ->bcc(env('MAIL_FROM_ADDRESS'), env('MAIL_FROM_NAME'))
            ->from(config('mail.from.address'), config('mail.from.name'));
    }
}

これを app/Mail/ 以下に作っといて、 \Mail::send(new MarkyMail($attributes)); で送る。