|
| 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