Use the setDataResidency setter to specify which host to send to:
Send to EU (hostname: https://api.eu.sendgrid.com/)
const sgMail = require('@sendgrid/mail');
sgMail.setDataResidency('eu');
const msg = {
to: '[email protected]',
from: '[email protected]',
subject: 'Hello world',
text: 'Hello plain world!',
html: '<p>Hello HTML world!</p>',
};
sgMail.send(msg);Send to Global region, this is also the default host, if the setter is not used
(hostname: https://api.sendgrid.com/)
const sgMail = require('@sendgrid/mail');
sgMail.setDataResidency('global');
const msg = {
to: '[email protected]',
from: '[email protected]',
subject: 'Hello world',
text: 'Hello plain world!',
html: '<p>Hello HTML world!</p>',
};
sgMail.send(msg);- Emails can only be sent to two hosts for now; 'eu' (https://api.eu.sendgrid.com/) and 'global' (https://api.eu.sendgrid.com/)
- The default hostname is https://api.sendgrid.com/
- The valid values for
regioninclient.setDataResidency(region)are onlyeuandglobal. Case-sensitive.