master

laravel/framework

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

Mailable.php

TLDR

The Mailable interface defines the contract for a class that represents a mailable email message. It provides methods for sending, queuing, and delivering the email message, as well as setting recipients, locale, and the mailer to be used.

Methods

send($mailer)

This method sends the message using the given mailer. The $mailer parameter can be an instance of Illuminate\Contracts\Mail\Factory or Illuminate\Contracts\Mail\Mailer. It returns an instance of \Illuminate\Mail\SentMessage or null.

queue(Queue $queue)

This method queues the given message for sending. The $queue parameter is an instance of Illuminate\Contracts\Queue\Factory. It returns mixed.

later($delay, Queue $queue)

This method delivers the queued message after a specified delay. The $delay parameter can be an instance of \DateTimeInterface, \DateInterval, or an integer representing seconds. The $queue parameter is an instance of Illuminate\Contracts\Queue\Factory. It returns mixed.

cc($address, $name = null)

This method sets the CC (carbon copy) recipients of the message. The $address parameter can be an object, array, or string. The $name parameter is optional and represents the name of the recipient. It returns self.

bcc($address, $name = null)

This method sets the BCC (blind carbon copy) recipients of the message. The $address parameter can be an object, array, or string. The $name parameter is optional and represents the name of the recipient. It returns $this.

to($address, $name = null)

This method sets the recipients of the message. The $address parameter can be an object, array, or string. The $name parameter is optional and represents the name of the recipient. It returns $this.

locale($locale)

This method sets the locale of the message. The $locale parameter is a string representing the locale. It returns $this.

mailer($mailer)

This method sets the name of the mailer that should be used to send the message. The $mailer parameter is a string representing the name of the mailer. It returns $this.

<?php

namespace Illuminate\Contracts\Mail;

use Illuminate\Contracts\Queue\Factory as Queue;

interface Mailable
{
    /**
     * Send the message using the given mailer.
     *
     * @param  \Illuminate\Contracts\Mail\Factory|\Illuminate\Contracts\Mail\Mailer  $mailer
     * @return \Illuminate\Mail\SentMessage|null
     */
    public function send($mailer);

    /**
     * Queue the given message.
     *
     * @param  \Illuminate\Contracts\Queue\Factory  $queue
     * @return mixed
     */
    public function queue(Queue $queue);

    /**
     * Deliver the queued message after (n) seconds.
     *
     * @param  \DateTimeInterface|\DateInterval|int  $delay
     * @param  \Illuminate\Contracts\Queue\Factory  $queue
     * @return mixed
     */
    public function later($delay, Queue $queue);

    /**
     * Set the recipients of the message.
     *
     * @param  object|array|string  $address
     * @param  string|null  $name
     * @return self
     */
    public function cc($address, $name = null);

    /**
     * Set the recipients of the message.
     *
     * @param  object|array|string  $address
     * @param  string|null  $name
     * @return $this
     */
    public function bcc($address, $name = null);

    /**
     * Set the recipients of the message.
     *
     * @param  object|array|string  $address
     * @param  string|null  $name
     * @return $this
     */
    public function to($address, $name = null);

    /**
     * Set the locale of the message.
     *
     * @param  string  $locale
     * @return $this
     */
    public function locale($locale);

    /**
     * Set the name of the mailer that should be used to send the message.
     *
     * @param  string  $mailer
     * @return $this
     */
    public function mailer($mailer);
}