Sending a custom email with Mailgun

Hi,

I have been working with this issue a few days:

http://support.backendless.com/t/business-logic-with-custom-event-to-add-a-mailgun-trigger
http://support.backendless.com/t/sending-a-custom-email-with-backendless

I have tested the custom business logic with Mailgun hostname in production mode and is still not working. I am still receiving a fault when I call to the custom business logic in production mode.

In debug mode I am able to send emails.

I have now approved and added the hostname = api.mailgun.net

But in the Mailgun docs I can see that the endpoint is:
https://api.mailgun.net/v3
https://documentation.mailgun.com/api-intro.html#introduction

So, I think the hostname could be = api.mailgun.net/v3, but I can´t introduce this string in your console browser to get the approval.

Please, any solution to finally solve this issue?

Thanks,

Jose

Hi Hose

api.mailgun.net’ should be enough

I have checked the mailgun service usage in custom business logic, having only ‘api.mailgun.net’ host approved. It works fine.

What error you faced this time ?

Hi Vitaly,

Thank you for your help.

When I am in production mode I receive a fault with Code 15000 with description:
“Custom business logic execution has been terminated because it did not complete in permitted time - 5 seconds”

Then I switch to debug mode, and I am able to send an email.

It´s a weird issue.

When I am in Intellij IDE I switch between modes running “npm run debug” or “npm run deploy” in its terminal console.

When I code “npm run debug”, the server is waiting for the request and the email is sent.

When I code “npm run deploy”, I can see this:

> coderunner deploy


11:30:10.254 - CodeRunner(tm) Backendless Debugging Utility v1.5.5
11:30:10.257 - Copyright(C) 2016 Backendless Corp. All rights reserved. 
11:30:10.486 - Building Model..
11:30:10.487 - Model Build completed
11:30:10.488 - Event handlers (1):
11:30:10.488 -   custom.sendMail  (app/handlers/custom-events/sendMail.js)
11:30:10.489 - Preparing app zip file for deployment..
11:30:10.493 - 4 files added into deployment archive
11:30:10.501 - Registering Code Runner on https://api.backendless.com
11:30:11.363 - Runner successfully registered.
11:30:11.363 - Registering Model on https://api.backendless.com
11:30:11.905 - Model successfully registered
11:30:11.905 - Publishing Model to server
11:30:13.499 - Successfully published

So, I confirm that the code is in production mode, but in this case I receive the fault.

Any idea for this weird issue?

Thanks.

Jose

Hi Jose,

What is your application id?

Regards,
Mark

Hi Mark,

My app id is:
6BB817B5-7BEA-0EB3-FF30-1F0949DE7D00

Thanks,
Jose

Hi Jose,

I have reproduced your problem. It must be a bug with an external hosts logic.
Internal task created BKNDLSS-12642.

Re-adding api.mailgun.net to external hosts list should help
Simply delete the old one and create a new one

Regards,
Vitaly

Hi Vitaly,

OK, I am going to delete and add a new external hostname = api.mailgun.net

Thanks,

Jose

Vitaly,

I have just tested and now it´s solved.

Now, I can send emails in production mode with custom business logic.

Thanks for your help!

Jose

Hello Jose,

We are glad to hear it,

Artur

I am currently having this exact same problem (also using mailgun). I have the external host setup correctly and I am getting timeouts in production (works correctly in debug mode). I get error “Service invocation failed by timeout”.

Hi,

Please create a dedicated topic for your problem.

Regards,
Sergey

Removing api.mailgun.net and adding it back again solved the issue for now.