Mail Goggles activates itself late at night on weekends when many users might have had a few too many drinks, making them more likely to write embarrassing messages to friends or partners.
It asks Gmail users to answer a series of mathematical questions before their message can be sent.
The simple addition and multiplication sums have to be completed within a time limit.
Jon Perlow, a Gmail engineer who created the software, announced the new product on Google's Gmail blog, explaining that he himself had sent some unfortunate late-night emails.
He said: "Sometimes I send messages I shouldn't send. Like the time I told that girl I had a crush on her over text message. Or the time I sent that late-night email to my ex-girlfriend that we should get back together."
"Gmail can't always prevent you from sending messages you might later regret, but today we're launching a new Labs feature I wrote called Mail Goggles which may help.
"Hopefully Mail Goggles will prevent many of you out there from sending messages you wish you hadn't. Like that late-night memo -- I mean mission statement -- to the entire firm."
Gmail users can set Mail Goggles to activate at any time they feel they might need protection.