1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

laravelのメール

Posted at

送信処理

// viewなし
Mail::raw('メール本文', function ($mail) {
    $mail->to('example@example.com');
});

// viewのみ
Mail::send('view.name', function ($mail) {
    $mail->to('example@example.com');
});

// 通常
Mail::to('example@example.com')->send(new HelloMail());

viewなし

<?php

namespace App\Mail;

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

class HelloMail extends Mailable
{
    use Queueable, SerializesModels;

    public function __construct()
    {
        //
    }

    public function build()
    {
        return $this->html('メール本文');
    }
}

サーバーなしでメール送信

.env
MAIL_MAILER=sendmail

参考

https://laravel.com/api/9.x/Illuminate/Mail/Mailable.html#method_html
https://laravel.com/api/9.x/Illuminate/Contracts/Mail/Mailer.html#method_raw

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?