TextMessage.php
TLDR
The TextMessage.php
file in the Illuminate\Mail
namespace defines a class named TextMessage
. This class is used to create a new text message instance and provides methods for embedding files or in-memory data in the message. Additionally, the class dynamically forwards missing methods to the underlying Message
instance.
Methods
embed($file)
This method is used to embed a file in the message and get the CID (Content ID) of the embedded file.
embedData($data, $name, $contentType = null)
This method is used to embed in-memory data in the message and get the CID (Content ID) of the embedded data.
__call($method, $parameters)
This method is a magic method that dynamically passes missing methods to the underlying Message
instance. It allows for seamless method forwarding.
<?php
namespace Illuminate\Mail;
use Illuminate\Support\Traits\ForwardsCalls;
/**
* @mixin \Illuminate\Mail\Message
*/
class TextMessage
{
use ForwardsCalls;
/**
* The underlying message instance.
*
* @var \Illuminate\Mail\Message
*/
protected $message;
/**
* Create a new text message instance.
*
* @param \Illuminate\Mail\Message $message
* @return void
*/
public function __construct($message)
{
$this->message = $message;
}
/**
* Embed a file in the message and get the CID.
*
* @param string|\Illuminate\Contracts\Mail\Attachable|\Illuminate\Mail\Attachment $file
* @return string
*/
public function embed($file)
{
return '';
}
/**
* Embed in-memory data in the message and get the CID.
*
* @param string|resource $data
* @param string $name
* @param string|null $contentType
* @return string
*/
public function embedData($data, $name, $contentType = null)
{
return '';
}
/**
* Dynamically pass missing methods to the underlying message instance.
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public function __call($method, $parameters)
{
return $this->forwardDecoratedCallTo($this->message, $method, $parameters);
}
}