Skip to content
Mitsuru Mutaguchi edited this page Sep 23, 2020 · 10 revisions

Sample

.env

// Setting to send mail with php mail() (php mail()でメール送信する設定)

MAIL_DRIVER=sendmail
MAIL_HOST=
MAIL_PORT=
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=
MAIL_FROM_ADDRESS=hello@example.com
MAIL_FROM_NAME=Example

.env (ex gmail)

// Not G Suite.

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=your_gmail@gmail.com
MAIL_PASSWORD=your_app_password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=your_gmail@gmail.com
MAIL_FROM_NAME=LaravelGmailSample

Plugin

use Illuminate\Support\Facades\Mail;
use App\Mail\ConnectMail;

class HogePlugin extends UserPluginBase
{

    public function index($request, $page_id, $frame_id, $errors = [])
    {
        // メール送信
        $to_mail_address = 'hello@example.com';
        $mail_subject = 'テスト件名';
        $mail_text = "本文\n本文2";
        Mail::to(trim($to_mail_address))->send(new ConnectMail(['subject' => $mail_subject, 'template' => 'mail.send'], ['content' => $mail_text]));
    }

Reference(参照・参考)

https://github.com/opensource-workshop/connect-cms/blob/master/app/Mail/ConnectMail.php

Laravel 5.5 メール - メール送信
https://readouble.com/laravel/5.5/ja/mail.html#sending-mail

Clone this wiki locally