Add optional onError handler for smtp requests