Skip to content

Latest commit

 

History

History
41 lines (37 loc) · 1.28 KB

File metadata and controls

41 lines (37 loc) · 1.28 KB

Choosing a data-residency to send messages to

Use the setDataResidency setter to specify which host to send to:

Send to EU (data-residency: https://api.eu.sendgrid.com/)

const client = require('@sendgrid/client');
const sgMail = require('@sendgrid/mail');
client.setDataResidency('eu');
const msg = {
  to: 'recipient@example.org',
  from: 'sender@example.org',
  subject: 'Hello world',
  text: 'Hello plain world!',
  html: '<p>Hello HTML world!</p>',
};
sgMail.setClient(client);
sgMail.send(msg);

Send to Global region, this is also the default host, if the setter is not used (data-residency: https://api.sendgrid.com/)

const client = require('@sendgrid/client');
const sgMail = require('@sendgrid/mail');
client.setDataResidency('global');
const msg = {
  to: 'recipient@example.org',
  from: 'sender@example.org',
  subject: 'Hello world',
  text: 'Hello plain world!',
  html: '<p>Hello HTML world!</p>',
};
sgMail.setClient(client);
sgMail.send(msg);

Limitations

  1. Emails can only be sent to two hosts for now; 'eu' (https://api.eu.sendgrid.com/) and 'global' (https://api.sendgrid.com/)
  2. The default data-residency is https://api.sendgrid.com/
  3. The valid values for region in client.setDataResidency(region) are only eu and global. Case-sensitive.