class Attachment extends Attachment (View source)

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
string|null $as

The attached file's filename.

from  Attachment
string|null $mime

The attached file's mime type.

from  Attachment
protected Closure $resolver

A callback that attaches the attachment to the mail message.

from  Attachment

Methods

static void
macro(string $name, object|callable $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Checks if macro is registered.

static void
flushMacros()

Flush the existing macros.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
__call(string $method, array $parameters)

Dynamically handle calls to the class.

static Attachment
fromPath(string $path)

Create a mail attachment from a path.

static Attachment
fromUrl(string $url)

Create a mail attachment from a URL.

static Attachment
fromData(Closure $data, string|null $name = null)

Create a mail attachment from in-memory data.

static Attachment
fromStorage(string $path)

Create a mail attachment from a file in the default storage disk.

static Attachment
fromStorageDisk(string|null $disk, string $path)

Create a mail attachment from a file in the specified storage disk.

$this
as(string|null $name)

Set the attached file's filename.

$this
withMime(string $mime)

Set the attached file's mime type.

mixed
attachWith(Closure $pathStrategy, Closure $dataStrategy)

Attach the attachment with the given strategies.

mixed
attachTo(Mailable|Message|MailMessage $mail, array $options = [])

Attach the attachment to a built-in mail type.

bool
isEquivalent(Attachment $attachment, array $options = [])

Determine if the given attachment is equivalent to this attachment.

Details

static void macro(string $name, object|callable $macro)

Register a custom macro.

Parameters

string $name
object|callable $macro

Return Value

void

static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

static bool hasMacro(string $name)

Checks if macro is registered.

Parameters

string $name

Return Value

bool

static void flushMacros()

Flush the existing macros.

Return Value

void

static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

static Attachment fromPath(string $path)

Create a mail attachment from a path.

Parameters

string $path

Return Value

Attachment

static Attachment fromUrl(string $url)

Create a mail attachment from a URL.

Parameters

string $url

Return Value

Attachment

static Attachment fromData(Closure $data, string|null $name = null)

Create a mail attachment from in-memory data.

Parameters

Closure $data
string|null $name

Return Value

Attachment

static Attachment fromStorage(string $path)

Create a mail attachment from a file in the default storage disk.

Parameters

string $path

Return Value

Attachment

static Attachment fromStorageDisk(string|null $disk, string $path)

Create a mail attachment from a file in the specified storage disk.

Parameters

string|null $disk
string $path

Return Value

Attachment

$this as(string|null $name)

Set the attached file's filename.

Parameters

string|null $name

Return Value

$this

$this withMime(string $mime)

Set the attached file's mime type.

Parameters

string $mime

Return Value

$this

mixed attachWith(Closure $pathStrategy, Closure $dataStrategy)

Attach the attachment with the given strategies.

Parameters

Closure $pathStrategy
Closure $dataStrategy

Return Value

mixed

mixed attachTo(Mailable|Message|MailMessage $mail, array $options = [])

Attach the attachment to a built-in mail type.

Parameters

Mailable|Message|MailMessage $mail
array $options

Return Value

mixed

bool isEquivalent(Attachment $attachment, array $options = [])

Determine if the given attachment is equivalent to this attachment.

Parameters

Attachment $attachment
array $options

Return Value

bool

Laravel Cloud is the best place to deploy Laravel, Nuxt, Express, Hono, Node.js, Bun, Go, Flask, Python, and more, with dedicated infrastructure available on AWS through Laravel Private Cloud.