Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Add mail/notification tags & metadata docs #7791

Merged
merged 2 commits into from
Mar 10, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 22 additions & 0 deletions mail.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- [View Data](#view-data)
- [Attachments](#attachments)
- [Inline Attachments](#inline-attachments)
- [Tags & Metadata](#tags-and-metadata)
- [Customizing The Symfony Message](#customizing-the-symfony-message)
- [Markdown Mailables](#markdown-mailables)
- [Generating Markdown Mailables](#generating-markdown-mailables)
Expand Down Expand Up @@ -470,6 +471,27 @@ If you already have a raw image data string you wish to embed into an email temp
</body>
```

<a name="tags-and-metadata"></a>
### Tags & Metadata

Some third-party email providers such as Mailgun and Postmark support message "tags" and "metadata", which may be used to group and track emails sent by your application. You may add tags and metadata to an email message via the `tag` and `metadata` methods:

/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->view('emails.orders.shipped')
->tag('shipment')
->metadata('order_id', $this->order->id);
}

If your application is using the Mailgun driver, you may consult Mailgun's documentation for more information on [tags](https://documentation.mailgun.com/en/latest/user_manual.html#tagging-1) and [metadata](https://documentation.mailgun.com/en/latest/user_manual.html#attaching-data-to-messages). Likewise, the Postmark documentation may also be consulted for more information on their support for [tags](https://postmarkapp.com/blog/tags-support-for-smtp) and [metadata](https://postmarkapp.com/support/article/1125-custom-metadata-faq).

If your application is using Amazon SES to send emails, you should use the `metadata` method to attach [SES "tags"](https://docs.aws.amazon.com/ses/latest/APIReference/API_MessageTag.html) to the message.

<a name="customizing-the-symfony-message"></a>
### Customizing The Symfony Message

Expand Down
20 changes: 20 additions & 0 deletions notifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- [Customizing The Mailer](#customizing-the-mailer)
- [Customizing The Templates](#customizing-the-templates)
- [Attachments](#mail-attachments)
- [Adding Tags & Metadata](#adding-tags-metadata)
- [Using Mailables](#using-mailables)
- [Previewing Mail Notifications](#previewing-mail-notifications)
- [Markdown Mail Notifications](#markdown-mail-notifications)
Expand Down Expand Up @@ -526,6 +527,25 @@ The `attachData` method may be used to attach a raw string of bytes as an attach
]);
}

<a name="adding-tags-metadata"></a>
### Adding Tags & Metadata

Tags and metadata can be added to the `MailMessage` - these are used by your email service for filtering/processing:

/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->greeting('Comment Upvoted!')
->tag('upvote')
->metadata('comment_id', $this->comment->id);
}

<a name="using-mailables"></a>
### Using Mailables

Expand Down