Ac mains current detector

take your ESP8266 and power it from a cell phone charger.
have it connect to the web.
tie in a battery and charge the battery from the same plug.
when you loose power, bingo ! you know you do not have power.
you would have battery and an internet connection via wifi so you can send you message.