Is it possible to send email via the backendless email apis that have both a list of BCC recipients and an attachment? They appear to be mutually exclusive. If that is not possible, is there a recommendation for sending mail from JS cloud code?
Mark, is there any additional setup I need to do to use the new feature? I switched to calling sendEmailFromTemplate. All recipients in the envelope receive the email, template values are substituted correctly, everything looks perfect, except no attachments are present. I ran a trace through my smtp server and the mail is coming through without the specified attachments.
If I send a test message from the template definition screen and select a file from the appropriate directory, the attachment arrives. But when I call the function from my API service, the attachment is ignored. For testing I am hard-coding the same file name that the test message uses, and the file definitely exists. No errors appear in the log files. If I hard-code a BOGUS filename, the message is still sent without errors, so I’m pretty sure the new attachment argument is being ignored.
My app id is 8149FCCE-07DA-F988-FFBB-6154872C9500 and the template I’m using is called ReturnsTemplate.
Unfortunately, I could not reproduce this problem in my application. Therefore, I will have some questions for you:
Do you send your emails through the API service?
Is the file you are sending in Files in Backendless?
Please send the snippet code with the problem so that we can reproduce it in our place.
Also, I want to clarify that in the Messaging>> Emails section, files that were added using the “Add attachments” button will only be sent if the message is sent from this screen. That is, if you add a file in edit mode and then send an email using the API, there will be no attachment.
Inna, thank you. Yes, I am sending via the console while running my API service in code runner in debug mode, so it isn’t currently deployed. I could deploy it if it would help. I’ve removed everything else in the service code and reduced it to the following:
I just ran this from the console with everything hard-coded as you see it, except for the email addresses. Both email accounts received the email perfectly, but without any hint of an attachment.
Logging shows this:
2021-10-20 16:04:07,414 | Global logger | INFO | Send custom template 'ReturnsTemplate' for 'blah@gmail.com' was published :
2021-10-20 16:04:07,429 | Global logger | INFO | Sending messages using the template 'ReturnsTemplate' is completed.The email template was sent to 1 recipients. :
Substituting garbage for the attachments file name argument leads to the same result. I do understand how the attachments in the templates definition window is used. The code I removed actually generates a dynamic PDF file, that will be emailed then deleted. I got rid of that just to isolate the mail function.
and deployed it to production. I verified in the coding tab that the service is as shown. The invocation returned a message id, logging said the mail was sent. But now I’m not even getting the message on either the recipients account or the bcc (different email providers, but same smtp server.) It’s been ten minutes, and no messages have arrived. That may not have anything to do with backendless, it looks like it is hitting my smtp server, but still with no attachment.
There is news. I didn’t get the messages after the production deployment because Google killed them as spam - I guess the attachment tickled their spam detection. So I actually DID get the attachment in production mode.
I tried it with the PDF file, and both the recipient and the BCC received everything perfectly.
My app id is 8149FCCE-07DA-F988-FFBB-6154872C9500.
If the code worked in production but doesn’t work in the debug mode, the only reason is the outdated Backendless NPM module. Please make sure to update your project dependencies. The latest Backendless npm module is v6.3.1.