Getting success or failure from sendEmail? Or another way to send emails?

In my Vision application we have an email screen where I use It works well enough most of the time, but we use an older SMTP email service provider and occasionally it would throw an error because the SMTP took too long to respond. However, even when we got that error, a minute or two later the email would send anyways.

So this was put into a try:except: statement, with the expectation they were always sending. I think we all know whats coming, eventually we found that some emails were not being sent but with no way to know this except people checking their outboxes/clients telling us they never received said email.

This all leads me to the fact that returns to me nothing. No matter what I don’t get any feedback on the failure or success of a email being sent. Is there anything I can do baout this? Has anyone else overcome this problem? Is there some 3rd party library people use for this? I don’t know where to go from here.

Debugging email is tricky, because there’s so many moving parts.

Ignition can only give you the errors it knows about. So that would be something really malformed about your email that we know it can’t be sent (such as no recipients), something obvious about the network (we can’t get a response from an SMTP server), or something the SMTP server tells us (like wrong username/password).

That last part is where most of the frustration of emails comes in. Once the SMTP server accepts the email from us, we don’t hear any more. So if the SMTP server has any problems at all, we have no way to know and tell you.


Ok. This confirms what I thought, that the issue was on the SMTP side. I do my sendEmail in a try/except clause and in the except block log that there was an error sending an email. However, I don’t see anything in my logs that sendEmail threw any error. I know it’s not anything like a malformed about how I call the function, and not a bad username/password. The only error I’ve ever got was the SMTP took to long.

These errors that sendEmail throw - do you know if they are python or java errors? Since we rarely get email errors and I can’t seem to make them happen I made the most general

    logger = system.util.getLogger('Email Failure')
    logger.warn("Email failed to send to blah blah")

Are sendEmail errors java errors and would they be caught with this statement? I’m wondering if maybe somehow I missed them.

They would be Java errors initially, but it looks like we wrap them up to appear as Python errors to you.

1 Like

Ok great so my try/except would catch them. So I didn’t initially get any error, and it must have been on the SMTP Server.

1 Like