Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/Illuminate/Mail/Mailable.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
use PHPUnit\Framework\Assert as PHPUnit;
use ReflectionClass;
use ReflectionProperty;
use Symfony\Component\Mailer\Header\MetadataHeader;
use Symfony\Component\Mailer\Header\TagHeader;
use Symfony\Component\Mime\Email;

class Mailable implements MailableContract, Renderable
{
Expand Down Expand Up @@ -870,6 +873,33 @@ public function attachData($data, $name, array $options = [])
return $this;
}

/**
* Add a tag header to the message when supported by the underlying transport.
*
* @param string $value
* @return $this
*/
public function tag($value)
{
return $this->withSymfonyMessage(function (Email $message) use ($value) {
$message->getHeaders()->add(new TagHeader($value));
});
}

/**
* Add a metadata header to the message when supported by the underlying transport.
*
* @param string $key
* @param string $value
* @return $this
*/
public function metadata($key, $value)
{
return $this->withSymfonyMessage(function (Email $message) use ($key, $value) {
$message->getHeaders()->add(new MetadataHeader($key, $value));
});
}

/**
* Assert that the given text is present in the HTML email body.
*
Expand Down
30 changes: 30 additions & 0 deletions src/Illuminate/Notifications/Messages/MailMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Mail\Markdown;
use Illuminate\Support\Traits\Conditionable;
use Symfony\Component\Mailer\Header\MetadataHeader;
use Symfony\Component\Mailer\Header\TagHeader;
use Symfony\Component\Mime\Email;

class MailMessage extends SimpleMessage implements Renderable
{
Expand Down Expand Up @@ -253,6 +256,33 @@ public function attachData($data, $name, array $options = [])
return $this;
}

/**
* Add a tag header to the message when supported by the underlying transport.
*
* @param string $value
* @return $this
*/
public function tag($value)
{
return $this->withSymfonyMessage(function (Email $message) use ($value) {
$message->getHeaders()->add(new TagHeader($value));
});
}

/**
* Add a metadata header to the message when supported by the underlying transport.
*
* @param string $key
* @param string $value
* @return $this
*/
public function metadata($key, $value)
{
return $this->withSymfonyMessage(function (Email $message) use ($key, $value) {
$message->getHeaders()->add(new MetadataHeader($key, $value));
});
}

/**
* Set the priority of this message.
*
Expand Down