eval { $dbh->begin(); # stuff... $mime_entity_instance->send(); } if ($@) { $dbh->rollback(); } else { $dbh->commit(); }