Skip to content

Commit 50b2baf

Browse files
committed
added docs for Parse.Cloud.sendMail
1 parent af52b8f commit 50b2baf

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ The Parse Server API Mail Adapter enables Parse Server to send emails using any
1818
- [Placeholders](#placeholders)
1919
- [Password Reset and Email Verification](#password-reset-and-email-verification)
2020
- [Localization](#localization)
21+
- [Cloud Code](#cloud-code)
22+
- [Example](#example)
23+
- [Parameters](#parameters)
2124
- [Need help?](#need-help)
2225

2326
# Installation
@@ -48,7 +51,7 @@ You can modify the script to use any other API you like or debug-step through th
4851
4952
# Configuration
5053
51-
An example configuation to add the API Mail Adapter to Parse Server could look like this:
54+
An example configuration to add the API Mail Adapter to Parse Server could look like this:
5255
5356
```js
5457
// Declare a mail client
@@ -188,6 +191,38 @@ Files are matched with the user locale in the following order:
188191
2. **Language** (locale `de-AT` matches file in folder `de` if there is no file in folder `de-AT`)
189192
3. **Default** (default file in base folder is returned if there is no file in folders `de-AT` and `de`)
190193

194+
# Cloud Code
195+
196+
Sending an email directly from Cloud Code is possible since Parse Server > 4.5.0. This adapter supports this convenience method.
197+
198+
## Example
199+
200+
If the `user` provided has an email address set, it is not necessary to set a `recipient` because the mail adapter will by default use the mail address of the `user`.
201+
202+
```js
203+
Parse.Cloud.sendEmail({
204+
templateName: "next_level_email",
205+
placeholders: { gameScore: 100, nextLevel: 2 },
206+
user: parseUser // user with email address
207+
});
208+
```
209+
210+
## Parameters
211+
212+
| Parameter | Type | Optional | Default Value | Example Value | Description |
213+
|----------------|--------------|----------|---------------|-----------------------------|------------------------------------------------------------------------------------------------|
214+
| `sender` | `String` | | - | `[email protected]` | The email sender address; overrides the sender address specified in the adapter configuration. |
215+
| `recipient` | `String` | | - | `[email protected]` | The email recipient; if set overrides the email address of the `user`. |
216+
| `subject` | `String` | | - | `Welcome` | The email subject. |
217+
| `text` | `String` | | - | `Thank you for signing up!` | The plain-text email content. |
218+
| `html` | `String` | yes | `undefined` | `<html>...</html>` | The HTML email content. |
219+
| `templateName` | `String` | yes | `undefined` | `customTemplate` | The template name. |
220+
| `placeholders` | `Object` | yes | `{}` | `{ key: value }` | The template placeholders. |
221+
| `extra` | `Object` | yes | `{}` | `{ key: value }` | Any additional variables to pass to the mail provider API. |
222+
| `user` | `Parse.User` | yes | `undefined` | - | The Parse User that the is the recipient of the email. |
223+
224+
225+
191226
# Need help?
192227

193228
- Ask on StackOverflow using the [parse-server](https://stackoverflow.com/questions/tagged/parse-server) tag.

0 commit comments

Comments
 (0)