Problem when sending email

1
Enonic version: Enonic XP 6.14.1
OS: Windows 10

Hi,

I have created a service to send emails and the code is:

When I call the service from a controller it does send the email ( it receive the email very quick) but the app completely stops and it never returns to the controller. It doesn’t throw any error so I don’t know what’s going on. Am I missing anything?

Regards.

I have found the issue!

1 Like

Anything that can enlighten the rest of us? :wink:

It was a silly thing. I was calling the service directly. Do you know if the try block is actually necessary here?

Hi Jorge!
Sorry for a late reply. I have been on vacation.
The try-block just depends on how you want the code to react, if anything should fail. If you drop the try-block, you have no control over how the error is propagated back in the code, and you are likely to get a 500 server error, or some error-page, depending on your setup. - With the try-block, you get a nice log-message, and a return value that you can treat, depending on the result.

Hope that helps!