Help integrating ESP8266 functionality into Arduino sketch

I have written a somewhat complex (for me :confused: ) sketch which runs on a Mega2560. It controls the level of water in a saltwater aquarium sump by turning a pump on/off, depending on optical sensor feedback. This runs 24 hours a day. There are a number of errors that can occur. These errors can be (and are) detected within the sketch, causing an alarm to sound. That's fine, if I'm at home. In cases where I'm not home I would like the sketch to send me an email. This is where my request for help comes into play.

I have my own website with a number of associated email accounts so I have written a .PHP file that can be called and accepts params with error texts, etc. It parses the passed params and sends a warning email to me.

Can someone suggest how I can integrate the calling of a ESP8266 based "send email" function into my Arduino sketch. Ideally, I would like to just call a function from the Arduino that passes 3 params to the ESP8266 which in turn sends ""

Sorry about the length of this question. Any help would be greatly appreciated as I have been unable to find anything related to what I need.

I google this with "arduino esp8266 send secure email"