Skip to content

Commit

Permalink
Merge branch 'release/1.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
DominusKelvin committed Nov 21, 2024
2 parents 54d7107 + 2effa46 commit cc37092
Show file tree
Hide file tree
Showing 5 changed files with 210 additions and 19 deletions.
4 changes: 2 additions & 2 deletions docs/boring-stack/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ For next steps, you have two options:
1. Open your project in your code editor and explore.
2. Begin by learning the basics, such as [routing](/boring-stack/routing) and [navigation](/boring-stack/navigation).

::: info Sailboat VS Code extension
Install the [Sailboat extension](https://marketplace.visualstudio.com/items?itemName=dominuskelvin.sailboat) which provides tooling for Sails.
::: info Official Sails VS Code extension
Install the official [Sails extension](https://marketplace.visualstudio.com/items?itemName=Sails.sails-vscode) which provides editor tooling support for Sails and The Boring JavaScript Stack.
:::

## Star the repo :star:
Expand Down
2 changes: 1 addition & 1 deletion docs/boring-stack/whats-in-the-stack.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ So if you enjoy writing React's JSX, you'd love The Boring JavaScript Stack as t

## Tailwind CSS

[Tailwind CSS](https://tailwindcss.com/), the utility-first CSS framework makes styling feels like cheating. It that the styling backbone of this stack.
[Tailwind CSS](https://tailwindcss.com/), the utility-first CSS framework makes styling feels like cheating. It serves as the styling backbone of this stack.

Since The Boring JavaScript Stack is about being pragmatic, what's better than Tailwind CSS in practicality, efficiency, and ensuring your styles are predictable and easy to manage?

Expand Down
20 changes: 16 additions & 4 deletions docs/mail/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ next:

To configure mail, create a `config/mail.js` configuration file. Let's look at all the possible configurations you can have in `config/mail.js`

## default
## `default`

The `default` config in `config/mail.js` tells Mail which mailer to use by default. The string passed to `default` must be the name of a registered mailer in the `mailers` object

Expand All @@ -40,7 +40,7 @@ mail: {
}
```

## mailers
## `mailers`

The `mailers` configuration object contains

Expand All @@ -63,9 +63,9 @@ The `mailers` configuration object contains
In Mail, a mailer is a configuration object that is registered in the `mailers` object in `config/mails.js` or in a `mail` object in `local.js` that specifies at the very least a transport that Mail will use in sending your emails.
:::

## from
## `from`

This config let you set a global from address for all your emails. It's really useful if your application sends emails from the same from address.
This config lets you set a global from address for all your emails. It's really useful if your application sends emails from the same from address.

By default Mail will use this address if no address is passed when you send an email with `sails.helpers.mail.send`

Expand All @@ -77,3 +77,15 @@ from: {
```

You can also set this config by specifying these two environment variables: `MAIL_FROM_NAME` and `MAIL_FROM_ADDRESS`.

## `replyTo`

This config lets you set a global reply-to address for all your emails. It's useful if you want replies to go to a specific address.

Mail will use this address by default if no `replyTo` address is provided when sending an email with `sails.helpers.mail.send`.

```js
replyTo: '[email protected]'
```

You can also set this config by specifying the environment variable `MAIL_REPLY_TO`.
201 changes: 190 additions & 11 deletions docs/mail/send-helper.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ next: false

Mail provides a `send` helper that is used to send your emails within your Sails applications. The `send` helper takes in several optional and required arguments like `mailer`, `template`, `templateData` etc.

## mailer
## `mailer`

The mailer to use for sending the email. This is optional because by default Mail will look for the mailer to use by checking for it in the following places:

Expand All @@ -27,63 +27,79 @@ The mailer to use for sending the email. This is optional because by default Mai
sails.helpers.mail.send.with({ mailer: 'resend' })
```

## template <Badge type="danger">required</Badge>
## `template`

This is a string matching an [email template](/mail/email-template) in `views/emails` without the file extension.

```js
sails.helpers.mail.send.with({ template: 'email-verify-account' })
```

## templateData
## `templateData`

A dictionary of data which will be accessible in your email template.

```js
sails.helpers.mail.send.with({ templateData: { fullName: 'Jack Sparrow' } })
```

## to <Badge type="danger">required</Badge>
## `to` <Badge type="danger">required</Badge>

The email address of the primary recipient.

```js
sails.helpers.mail.send.with({ to: '[email protected]' })
```

## toName
## `toName`

The name of the primary recipient

```js
sails.helpers.mail.send.with({ toName: 'Jack Sparrow' })
```

## subject
## `cc` <Badge>SMTP</Badge> <Badge>Resend</Badge>

The email addresses to send a carbon copy of the mail to.

```js
sails.helpers.mail.send.with({ cc: ['[email protected]'] })
```

## `bcc` <Badge>SMTP</Badge> <Badge>Resend</Badge>

The email addresses to send a blind carbon copy of the mail to.

```js
sails.helpers.mail.send.with({ cc: ['[email protected]'] })
```

## `subject`

The subject of the email.

```js
sails.helpers.mail.send.with({ subject: 'Verify email' })
```

## from
## `from`

The from email to use to send the email. This isn't required because you can specify a [global from](/mail/configuration#from)

```js
sails.helpers.mail.send.with({ from: '[email protected]' })
```

## fromName
## `fromName`

The from name to use to send the email. This isn't required because you can specify a [global from](/mail/configuration#from)

```js
sails.helpers.mail.send.with({ fromName: 'The Boring JavaScript Stack' })
```

## layout
## `layout`

The email layout to use for this email. This isn't required because by default Mail will look for a layout called `layout-email`.

Expand All @@ -92,7 +108,7 @@ However with `layout` you can pass an override and chose another layout to use o
### Specify a layout

```js
await sails.helpers.mail.send.with({ layout: 'layout-accout' })
await sails.helpers.mail.send.with({ layout: 'layout-account' })
```

### Disable layout
Expand All @@ -101,14 +117,177 @@ await sails.helpers.mail.send.with({ layout: 'layout-accout' })
await sails.helpers.mail.send.with({ layout: false })
```

## text
## `text`

Specify email plain text.

```js
await sails.helpers.mail.send.with({ text: 'Verify your email' })
```

## `attachments`

An optional array of attachment objects. Each attachment object should have the following properties:

- `filename`: The name of the file.
- `path`: The path to the file.
- `contentType`: The MIME type of the file (optional).
- `content`: String, Buffer or a Stream contents for the attachment (optional).

```js
await sails.helpers.mail.send.with({
to: '[email protected]',
toName: 'Jack Sparrow',
template: 'email-verify-account',
templateData: { token: '3828bsbababvbas', fullName: 'Jack Sparrow' },
attachments: [
{
filename: 'adventure-log.txt',
content: 'The journey begins...'
},
{
filename: 'treasure-map.txt',
content: new Buffer('X marks the spot!', 'utf-8')
},
{
filename: 'crew-list.txt',
path: '/path/to/crew-list.txt'
},
{
filename: 'ship-photo.jpg',
path: '/path/to/ship-photo.jpg',
contentType: 'image/jpeg'
}
]
})
```

## `replyTo` <Badge>SMTP</Badge> <Badge>Resend</Badge>

An email address that will appear on the Reply-To: field. This isn't required because you can specify a [global replyTo](/mail/configuration#replyTo).

```js
sails.helpers.mail.send.with({ replyTo: '[email protected]' })
```

## `category` <Badge>Mailtrap</Badge>

The category of the email.

```js
await sails.helpers.mail.send.with({
category: 'verify'
})
```

## `customVariables` <Badge>Mailtrap</Badge>

An object with custom variables to use in the email.

```js
await sails.helpers.mail.send.with({
customVariables: {
shipName: 'Black Pearl',
captain: 'Jack Sparrow'
}
})
```

## `templateUuid` <Badge>Mailtrap</Badge>

The UUID of the template to use.

```js
await sails.helpers.mail.send.with({
templateUuid: '123e4567-e89b-12d3-a456-426614174000'
})
```

## `templateVariables` <Badge>Mailtrap</Badge>

An object with the variables to use in the template.

```js
await sails.helpers.mail.send.with({
templateUuid: '123e4567-e89b-12d3-a456-426614174000',
templateVariables: {
shipName: 'Black Pearl',
captain: 'Jack Sparrow'
}
})
```

## `testInboxId` <Badge>Mailtrap</Badge>

The ID of the test inbox to use.

```js
await sails.helpers.mail.send.with({
to: '[email protected]',
toName: 'Jack Sparrow',
template: 'email-verify-account',
templateData: { token: '3828bsbababvbas', fullName: 'Jack Sparrow' },
testInboxId: 5353939
})
```

## `react` <Badge>Resend</Badge>

If you are using [React Email](https://react.email/), you can pass the the React component you used in writing the message to `react`.

:::code-group

```jsx[important-message.jsx]
import * as React from 'react'
import { Html, Button, Container, Heading, Text } from '@react-email/components'
export default function Email(props) {
const { url, recipientName } = props
return (
<Html lang="en">
<Container>
<Heading>Ahoy, {recipientName}!</Heading>
<Text>We have an important message for you. Click the button below to read it:</Text>
<Button href={url}>Read Message</Button>
<Text>Fair winds and following seas,</Text>
<Text>The Black Pearl Crew</Text>
</Container>
</Html>
)
}
```

```js [signup.js]
const Email = require('../../assets/emails/important-message')

await sails.helpers.mail.send.with({
react: <Email url="https://example.com" recipientName="Jack Sparrow" />,
to: '[email protected]',
toName: 'Jack Sparrow'
})
```

:::

:::tip
Make sure you have `@react-email/components` installed to use React components as email
:::

## `scheduledAt` <Badge>Resend</Badge>

Schedule email to be sent later. The date should be in natural language (e.g.: in 1 min) or ISO 8601 format (e.g: 2024-08-05T11:52:01.858Z).

```js
await sails.helpers.mail.send.with({
to: '[email protected]',
toName: 'Jack Sparrow',
template: 'email-verify-account',
templateData: { token: '3828bsbababvbas', fullName: 'Jack Sparrow' },
scheduledAt: '2024-08-05T11:52:01.858Z'
})
```

## Examples

### Send email with template
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sailscasts-docs",
"version": "1.4.0",
"version": "1.5.0",
"private": true,
"description": "The official docs hub for Sailscasts",
"scripts": {
Expand Down

0 comments on commit cc37092

Please sign in to comment.