I've used mailgun mostly for receiving emails from customers to my authorized email that I add on my account.
But when I try to do the reverse, it gives me an error:
Error: Sandbox subdomains are for test purposes only. Please add your own domain or add the address to authorized recipients in Account Settings.
at IncomingMessage.<anonymous> (E:\TheLittleVoice\theLittleVoice\node_modules\mailgun-js\lib\request.js:327:17)
at IncomingMessage.emit (events.js:327:22)
at endReadableNT (_stream_readable.js:1220:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
statusCode: 400
}
My use case:
const data = {
from: email,
to: "abc@gmail.com", //authorized at mailgun
subject: "Welcome to the Community",
html: firstTimeMessage(name),
};
mg.messages().send(data, function (error, body) {
if (error) {
console.log(error);
cb(error, null);
} else {
console.log(body);
cb(null, body);
}
});
Above code works but the following gives my error (mentioned above):
const data = {
from: "abc@gmail.com", //authorized at mailgun
to: email,
subject: "Welcome to the Community",
html: firstTimeMessage(name),
};
mg.messages().send(data, function (error, body) {
if (error) {
console.log(error);
cb(error, null);
} else {
console.log(body);
cb(null, body);
}
});
All I did is swap from and to fields. Is this not allowed? If not how can I achieve this?