I would look at using the Sinon.js helper library. You can mock the XMLHttpRequest object to intercept the mail request and make sure your plugin code sends images correctly. In particular, look at this part of the Sinon.js documentation:
http://sinonjs.org/docs/#server
source
share