Backendless Support
 
In Progress

v4 Codeless: Sending email does not always work

Hi all,

I have a timer that should run every night at midnight, do some processing and send a report email based on the results of a query. (I do have a custom SMTP server configured)

When that codeless timer runs, there is a for loop that should iterate over my result set, and send an email for each object found, accordingly. The problem seems to be that 9 times out of 10, only one of those emails gets sent, say if there are N in the result-set. (I also have print outs throughout, which shows that all of the correct logic is hit, up until the "send email" codeless block, which is as far as I can go). I'm wondering if something is stopping it from sending, since it is so close together via seconds / milliseconds in the loop, that it is being blocked by one of the servers?

Is there any way to check outgoing email logs against my SMTP server from backendless' side? I'm trying to gain as much context to try and figure out a pattern as to why this is happening / exactly how I can replicate it. I've also been in talks with my host to see if they can deduce if the issue is on their end via any logs on their end.

App ID is A324EB2B-1BF5-EB0A-FF36-62F47D198E00.

Much appreciated,

R

Leave a Comment

Comments (9)

photo
1

Hey Renato

Pretty sure that the problem is not in email API, I've checked for absence/presence of queue of tasks as well and there is no such. I'll check your codeless logic and logs for errors during sending emails. I'll get back here as soon as I get any results.

Best Regards

photo
1

Thank you, Anton.

Just FYI, I invoked the timer again today (with some new associated demo data) and am expecting two emails to be sent out, but can confirm only one made it to my inbox. Host will be checking their logs again for this new demo scenario. Mind checking the queue again to confirm that nothing is "stuck"?

I have a hunch that maybe something is getting marked as "spam" on the SMTP side and thus explaining why only one gets delivered. Do you think an SPF record allowing the backendless service on their end could potentially help with this?

Renato

photo
1

More context - Host just confirmed that (of the demo scenario I just created today) there is only one log that they can see (which matches the actual email that was delivered), suggesting that backendless is not delivering / sending it through to the SMTP server.

Let me know if there's any other info I can get you. Appreciate you looking into this! :)

Renato

photo
photo
1

Hey!

Checked again against the presence of queue of tasks and there is no such. In case it was the reason - you'd have already received the missing email. And there's a really low probability that it was caused by queue as far as you received part of the emails at the expected time.

What I'd recommend is to set an afterSendEmail handler which will be waiting for email sending events. Add code which will log smth, in this case every time when email API is called you will see whether it's actually called or not by reviewing the log file. This would be the point from which we can start investigating the cause of such behavior.

We've tried testing the API blocks and sending email directly in code with Google SMTP and received all the expected emails.

Looking forward to hearing from you the results!

BR Anton

photo
1

Hi Anton - thanks for the suggestion. I created both a beforeSendEmail and afterSendEmail handler with a simple print block, but the print value is not listed anywhere in my logs after deploying & invoking again.

I created the handlers as so:

4b0ef21837192f896ff58838b8df5cb3

I did double check that is the correct model for the code in question. Am I missing something?

Renato

photo
1

Renato,

It was a bad idea to offer setting event handlers for email sending event as far as API calls made out of business logic are not triggering the deployed handlers.. :) Sorry for wasting your time.

Would you mind if we change SMTP server to ours for a while just on a period of testing. We will change the email settings and you will repeat your test again. Would that be ok?

Anton

photo
1

Hi Anton,

That’s no problem!

Let me know when you’d like me to re-run the test :)

Renato

photo
photo
1

Hello, Renato,

I have changed smtp server, please make your tests and let us know about results

photo
1

Thank You Sergey,

I have re-run the test with your server settings now, and the two emails (as a result of my test data) did come through.

I was going to reset to my SMTP and test with TLS as the option (since the setting was SSL before), but I cannot save any of the settings. I get an error message that the request timed out.

Update: When it does look like it "worked", when the page is refreshed, the new values are not persisted.

Update 2: If I select the setting as SSL, it will properly "save" in backendless. If I select TLS, it will not. Does it not save if it cannot connect to the SMTP server with the given settings? It's a little odd, because if I use TLS, and click test, it says the test has passed?

Renato

photo