/
adding-attachments-email-notification.liquid
80 lines (61 loc) · 2.33 KB
/
adding-attachments-email-notification.liquid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
---
converter: markdown
metadata:
title: Adding Attachments to an Email Notification
description: This guide will help you attach files to an Email Notification.
---
This guide will help you attach files to an Email Notification.
## Requirements
To follow the steps in this tutorial, you should understand the concept of Email Notifications. You'll use the Email Notification you created in a previous tutorial.
* [Creating an Email Notification](/developer-guide/notifications/creating-email-notification)
## Steps
Attaching a file to an Email Notification is a one-step process:
<div data-autosteps></div>
### Step 1: Include `attachments` JSON in Email Notification
Add the `attachments` JSON to the Email Notification created in a previous tutorial:
##### app/emails/welcome_user.liquid
```liquid
{% raw %}
---
to: '{{ form.email }}'
from: 'Example Marketplace <info@example.com>'
reply_to: no-reply@example.com
subject: 'Welcome {{ form.first_name }} in our marketplace!'
layout: mailer
attachments: >
{
"logo.jpg": {
"url": "https://uploads.prod01.oregon.platform-os.com/instances/1/assets/images/svg/platformos-logo.svg"
}
}
---
<h1>Hi {{ form.first_name }}!</h1>
<p>Welcome in our marketplace!</p>
{% endraw %}
```
Now, when you send an email, the attachment will be included.
You can use `liquid` in the `attachments` field, as long as it evaluates to valid JSON. The expected JSON is in the following format:
```json
{
"<file_name_user_will_see1>": {
"url": "<url to the attachment>"
},
"<file_name_user_will_see2>": {
"url": "<another url to the attachment>"
}
}
```
You can also mark any attachment's `Content-Disposition` as `inline`.
Inline attachment means that some types of files will be displayed inside the email content by some email clients.
By default, attachments have `Content-Disposition` set to `attachment`, which means they are only available to download in email clients.
```json
{
"my_file": {
"url": "<url to the attachment>",
"inline": "true"
}
```
{% include "alert/note", content: "You can include up to 9 attachments, and the total size cannot exceed 20MB." %}
## Next steps
Congratulations! You have sent an Email Notification with an attachment. Now you can learn about creating an SMS Notification.
* [Creating an SMS Notification](/developer-guide/notifications/creating-sms-notification)