0

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?

Surya Mahla
  • 483
  • 5
  • 20
  • 1
    Does this answer your question? [Can I send email with mailgun sandbox domain under my local OS?](https://stackoverflow.com/questions/68150905/can-i-send-email-with-mailgun-sandbox-domain-under-my-local-os) – tevemadar Jul 27 '21 at 11:11

1 Answers1

0

You should not use a Sandbox for sending out emails. You should use your one domain. This detailed description may help you: Can I send email with mailgun sandbox domain under my local OS?

FredyWenger
  • 2,236
  • 2
  • 32
  • 36