Sending a custom email with Backendless

Hi,
In the past days I was trying to implement a custom business logic to send emails through Mailgun in Backendless. I spent hours to understand your process to implement custom business logics. I asked in this forum support and an agent from you helped me to to achieve the implementation. He never told me during the process about Mailgun or other email platforms are forbidden in your platform.
Yesterday, I received this email from you:
Hello Jose Miguel Galván,

External host ‘Mailgun’ for custom business logic has been rejected. The host violates Backendless terms of use. You will see the updated status for the host in Backendless console (Manage > App Settings).

Regards,
Backendless team

In Parse, I have apps with Cloud Code triggers connected to Mailgun and Mailchimp and I never have had a problem using these hosts.
So, at this point, then I have to use Retrofit in Android and a wrapper in iOS with AFN to send emails through the frontends.
In my opinion, I know that you have an outstanding support service and this is one of the reasons that I am working with you, but in this case, I think that the limits have to be more clear, because now I have to change a few implementations in our code.
What about your custom sending email system? Do you have wrapped it in the iOS and Android SDKs? Or I have to use it in a native way, like Retrofit or AFNetworking?
Thanks,
Jose

Hi! Could you provide your application id?

I’m investigating why this external host was rejected.

Hi Kate,

My app id is:

6BB817B5-7BEA-0EB3-FF30-1F0949DE7D00

I´ll wait for your comments.

Thanks.

Jose

Instead of “Mailgun” try to add endpoint like “api.mailgun.net” (full name of endpoint).

What about your custom sending email system?
You can use sendEmail() methods implemented in SDKs:
https://backendless.com/documentation/messaging/android/messaging_sending_email_rest.htm

Ok Kate.

I just added it and is pending of approval.

Thanks!

Jose

api.mailgun.net APPROVED.

Great Kate.

Thanks,

Jose

Kate would you mind helping me on setting up custom business logic? I have done the downloads, unzipped but when i run coderunner it disconects

@Jose please assist me on the ide part of custom business logic. The agents dont seem to reply to my question

samuel, please add new support topic with description of the problem.

Samuel,

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

Jose

Hi,

I have tested the custom business logic with Mailgun hostname in production mode and is still not working.

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

For testing I created event handler and added external host api.mailgun.net (adding /v3 for host approval is not required):

@Asset( "*" )
public class GenericTableEventHandler extends com.backendless.servercode.extension.PersistenceExtender<HashMap>
{
 
 @Override
 public void beforeCreate( RunnerContext context, HashMap hashmap) throws Exception
 {
 try {
 URL url = new URL("[url=https://api.mailgun.net/v3]https://api.mailgun.net/v3"[/url];);
 URLConnection connection = url.openConnection();
 BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
 String nextString = null;
 StringBuilder result = new StringBuilder();

 while ((nextString = in.readLine()) != null) {
 result.append(nextString);
 }
 in.close();

 } catch (Throwable e) {
 Logger logger = Backendless.Logging.getLogger("Logger.errors");
 logger.info("external host info:" + e.toString());
 }
 }
}

I deployed handler to production and invoke it. In log (File service -> logging folder )
I receive following error:
2016-05-20 12:52:58,106 | Logger.errors | INFO | external host info:java.io.FileNotFoundException: https://api.mailgun.net/v3The same error appears if open this address in browser: https://monosnap.com/file/5N8fT0vYEHBlUpPtIzgP8SZFwnzhPt
Which error you receive?

Hi Kate,

I am also with Vitaly in this topic:
http://support.backendless.com/t/sending-a-custom-email-with-mailgun

In debug mode I am able to send emails but not in production mode.

Thanks,
Jose