Mailgun Stopped Working For Me

I have been using Mailgun for over two years and I now get the following error message:

2016-12-14 14:59:47 UTC-5 [Agent] Error 400 sending Email message (MailGun): { "message": "Sandbox subdomains are for test purposes only. Please add your own domain or add the address to authorized recipients in domain settings." }

I have not changed the code again in two years.

My function:

//************************ MailGun function
function sendEmailMailGun(subject, message)
{
local from = “postmaster@sandbox (id taken out).mailgun.org”;
local to = "XXXXXXX@gmail.com";
local apikey = “key-(id taken out)”;
local domain = “sandbox(id taken out).mailgun.org”;
local req = http.post(“https://api:” + apikey + "@api.mailgun.net/v2/" + domain + “/messages”, {“Content-Type”: “application/x-www-form-urlencoded”}, “from=” + from + “&to=” + to + “&subject=” + subject + “&text=” + message);
local res = req.sendsync();

    //server.log(auth);
    if(res.statuscode != 200)
    {
        server.log("Error " + res.statuscode + " sending Email message (MailGun): " + res.body );
    } else {
        server.log("Sent Email with MailGun ");
            }
}

//****************************************

Any idea why it stopped working?

As it says on the tin… “Sandbox subdomains are for test purposes only”. I think Mailgun probably just carried out some housekeeping and blocked your account from continued use of the sandbox email id. Not bad that you got 2 years use out of it. Maybe set up a new account with Mailgun or do as it says and link a web domain to Mailgun.