Skip to content

Commit 2f7c9ea

Browse files
committed
Add an example readme
1 parent 50a8691 commit 2f7c9ea

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Choosing a hostname to send messages to
2+
3+
Use the `setDataResidency` setter to specify which host to send to:
4+
5+
Send to EU (hostname: `https://api.eu.sendgrid.com/`)
6+
```js
7+
const sgMail = require('@sendgrid/mail');
8+
sgMail.setDataResidency('eu');
9+
const msg = {
10+
to: 'recipient@example.org',
11+
from: 'sender@example.org',
12+
subject: 'Hello world',
13+
text: 'Hello plain world!',
14+
html: '<p>Hello HTML world!</p>',
15+
};
16+
sgMail.send(msg);
17+
```
18+
Send to Global region, this is also the default host, if the setter is not used
19+
(hostname: `https://api.sendgrid.com/`)
20+
```js
21+
const sgMail = require('@sendgrid/mail');
22+
sgMail.setDataResidency('global');
23+
const msg = {
24+
to: 'recipient@example.org',
25+
from: 'sender@example.org',
26+
subject: 'Hello world',
27+
text: 'Hello plain world!',
28+
html: '<p>Hello HTML world!</p>',
29+
};
30+
sgMail.send(msg);
31+
```
32+
33+
## Limitations
34+
35+
1. Emails can only be sent to two hosts for now; 'eu' (https://api.eu.sendgrid.com/) and 'global' (https://api.eu.sendgrid.com/)
36+
2. The default hostname is https://api.sendgrid.com/
37+
3. The valid values for `region` in `client.setDataResidency(region)` are only `eu` and `global`. Case-sensitive.

0 commit comments

Comments
 (0)