master

laravel/framework

Last updated at: 29/12/2023 09:21

Mailer.php

TLDR

The Mailer.php file is an interface that defines methods for mailing a mailable class instance. It provides methods for sending messages, including raw text messages and messages using views.

Methods

to

This method begins the process of mailing a mailable class instance. It takes a $users parameter and returns an instance of PendingMail from the Illuminate\Mail namespace.

bcc

This method begins the process of mailing a mailable class instance. It takes a $users parameter and returns an instance of PendingMail from the Illuminate\Mail namespace.

raw

This method sends a new message with only a raw text part. It takes a $text parameter and a $callback parameter. It returns an instance of SentMessage from the Illuminate\Mail namespace.

send

This method sends a new message using a view. It takes a $view parameter which can be a Mailable instance, a string, or an array. It also takes an optional $data array and an optional $callback closure or string. It returns an instance of SentMessage from the Illuminate\Mail namespace.

<?php

namespace Illuminate\Contracts\Mail;

interface Mailer
{
    /**
     * Begin the process of mailing a mailable class instance.
     *
     * @param  mixed  $users
     * @return \Illuminate\Mail\PendingMail
     */
    public function to($users);

    /**
     * Begin the process of mailing a mailable class instance.
     *
     * @param  mixed  $users
     * @return \Illuminate\Mail\PendingMail
     */
    public function bcc($users);

    /**
     * Send a new message with only a raw text part.
     *
     * @param  string  $text
     * @param  mixed  $callback
     * @return \Illuminate\Mail\SentMessage|null
     */
    public function raw($text, $callback);

    /**
     * Send a new message using a view.
     *
     * @param  \Illuminate\Contracts\Mail\Mailable|string|array  $view
     * @param  array  $data
     * @param  \Closure|string|null  $callback
     * @return \Illuminate\Mail\SentMessage|null
     */
    public function send($view, array $data = [], $callback = null);
}