Handle errors during publishing
Currently the publish_email_events does not handle any errors that might occur during publishing.
This can be achieved by implementing a callback function that handles exceptions. See this snippet for an example implementation; note however that this implementation only prints the exceptions which might not be sufficient for our use case.