fixed bug where email would send even on successful api call