How to handle error from sending an email

Post any question regarding setting up, running or configuring Verj.io Workflow

Moderators: Jon, Steve, Ian, Dave

systemsolutions
Ebase User
Posts: 19
Joined: Tue Oct 03, 2017 3:33 pm
Location: USA

How to handle error from sending an email

#1

Postby systemsolutions » Tue Jan 15, 2019 7:38 pm

I'm having trouble figuring out how to handle an email error. Current error is invalid email address for the Send To.

On my email resource I had the Success of the email is critical flag checked which caused my workflow task to be marked as failed, which is correct. If I uncheck that box and run the workflow, the sendemail call always returns true, even though the email fails.

How can I handle the failed state and do something? Ultimately I want to go to a different task to send an email and then reassign a previous task. I've got that part done, just need to handle the email resource failing.
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

Re: How to handle error from sending an email

#2

Postby Jon » Wed Jan 16, 2019 9:20 am

If you're using Javascript have a look at the Javadoc for sendmail. When the email resource is not marked as critical it will return false when the email fails. So you can code something like:

Code: Select all

if (!resources.myemail.sendmail())
{
  .. handle the error
}
Alternatively, if it's marked as critical, an exception is throws. So you need:

Code: Select all

try
{
  resources.myemail.sendmail()
}
catch (e)
{
  ..handle the error
}
If you're using FPL, don't mark the email resource as critical, then check the response from sendmail is "OK".
0 x

systemsolutions
Ebase User
Posts: 19
Joined: Tue Oct 03, 2017 3:33 pm
Location: USA

Re: How to handle error from sending an email

#3

Postby systemsolutions » Thu Jan 17, 2019 4:34 pm

I'll try it using your syntax. When I tried before turning off that flag it was always return true.
0 x

systemsolutions
Ebase User
Posts: 19
Joined: Tue Oct 03, 2017 3:33 pm
Location: USA

Re: How to handle error from sending an email

#4

Postby systemsolutions » Fri Jan 18, 2019 3:52 am

Thank you!!!! It's now working perfect.
0 x

systemsolutions
Ebase User
Posts: 19
Joined: Tue Oct 03, 2017 3:33 pm
Location: USA

Re: How to handle error from sending an email

#5

Postby systemsolutions » Fri Jan 18, 2019 4:17 am

Wait, I typed too fast.

The call to the sendmail is always returning true, even when sending to an invalid email address.
0 x

systemsolutions
Ebase User
Posts: 19
Joined: Tue Oct 03, 2017 3:33 pm
Location: USA

Re: How to handle error from sending an email

#6

Postby systemsolutions » Fri Jan 18, 2019 6:18 pm

I set up a simple form with fields and an email resource. I tried both of the below snippets, but the sendmail never returned a false nor an error. Yet I get an email bounced back error to the inbox that my email settings are using.

try
{
resources.VelocityEmail.sendmail()
}
catch (e)
{
print("Error Occurred")
}

or

if (!resources.VelocityEmail.sendmail())
{
print("Error Occurred")
}
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

Re: How to handle error from sending an email

#7

Postby Segi » Fri Jan 18, 2019 11:38 pm

It sounds like if its bouncing back to the sender it means that as far as Ebase is concerned, it was correctly delivered but its getting bounced back by the email server. This is an entirely different issue that you won't be able to catch in Ebase
0 x

systemsolutions
Ebase User
Posts: 19
Joined: Tue Oct 03, 2017 3:33 pm
Location: USA

Re: How to handle error from sending an email

#8

Postby systemsolutions » Sat Jan 19, 2019 12:02 am

Ah crud, that sounds about right.

Luckily I think I have a work around.

Thanks
0 x


Who is online

Users browsing this forum: No registered users and 2 guests