gmail.js icon indicating copy to clipboard operation
gmail.js copied to clipboard

How to stop Gmail from sending an email?

Open KonceptGeek opened this issue 6 years ago • 1 comments

Hi, I have a before.send_message observe function that performs some business logic. Is there a way to cancel the sending of the email based on the business logic and show the compose window again?

gmail.observe.before("send_message", function (url, body, data, xhr) {
    if (gmail.check.is_google_apps_user()) {
        var emailId = data[1];
        var from = {'name': data[2][3], 'email': data[2][2]};
        var to = _.map(data[3], (d) => ({'name': d[3], 'email': d[2]}));
        var cc = _.map(data[4], (d) => ({'name': d[3], 'email': d[2]}));
        var bcc = _.map(data[5], (d) => ({'name': d[3], 'email': d[2]}));
        var subject = data[8];
        var content = data[9];
        //perform some business logic and possibly cancel the sending and show the compose window again.
    }
});

KonceptGeek avatar Feb 02 '19 01:02 KonceptGeek

After Gmail transitioned to the new data-model, I don't think there's any way to prevent sending any more. Someone please correct me if I'm wrong.

Either way, as far as I know, only after.send_message is now meaningfully supported.

josteink avatar Feb 02 '19 21:02 josteink

Old issue is old. Closing.

josteink avatar Oct 11 '23 08:10 josteink