Electric imp email monthly report

Hi I am trying to get my Imp to email the log through mail gun but I am having trouble can someone help please

`function buttonPress() {
local state = button.read();
if (state == 1) {
// when the button is released
server.log(“release”);
} else {
// when the button is pressed
server.log(“press”);
}
const API_KEY = “key-cff14c0d6aa085b70ff46aeff716568d”;
const MAILGUN_URL = “api.mailgun.net/v2/sandboxd656ccbe554a4b88ab005f27fd2bccd3.mailgun.org”;
const MAILGUN_DOMAIN = “sandboxd656ccbe554a4b88ab005f27fd2bccd3.mailgun.org”;
const FROM = “First Last postmaster@sandboxd656ccbe554a4b88ab005f27fd2bccd3.mailgun.org”;
const TO = “First Last joshreid76@hotmail.com”;
const EMAIL_MESSAGE = “I am sending email through MailGun from an Electric Imp!”;

function send_mailgun_email( pin1Value ) {
local url = format(“https://api:%s@%s%s/messages”, API_KEY, MAILGUN_URL, MAILGUN_DOMAIN);
local headers = {“Content-Type”: “application/x-www-form-urlencoded”};
local body = http.urlencode({from=FROM, to=TO, subject=pin1Value, text=EMAIL_MESSAGE});
server.log( body );

http.post(url,headers,body).sendasync(function(res) {
    if (res.statuscode != 200) {
        server.error("Mailgun error: " + res.statuscode + " => " + res.body);
    } else {
        try {
            server.log(res.body);
        } catch (e) {
            server.error("Mailgun error: " + e)
        }
    }
})

}

// Use this with example device code
// Uncomment the three lines below
device.on(“impValue”, function(data) {

send_mailgun_email( data );

});

}
`

this line comes up error
local url = format(“https://api:%s@%s%s/messages”, API_KEY, MAILGUN_URL, MAILGUN_DOMAIN);

Why?

I did something like this before.

I keep getting an error index pin1 does not exist?

fancy

@joshreid, your URL line error may because that looks like a malformed URL to me. Shouldn’t have a colon in there, ie. ‘api.’ not ‘api:’ and I’m not sure you can have an @ symbol in there, either.

https://discourse.electricimp.com/discussion/3319/can-anyone-help-me