I'm trying to send an email from my Android Firebase app to an arbitrary email address using the Trigger Email extension. Following this tutorial, I first set up the outbound mail service using sendGrid and tested it. Next, I created a Firestore documents collection named 'email' and set up some security rules for the collection. Finally, I installed the Trigger Email extension into my project and specified sender address, etc.
The code that adds email documents to the collection is as follows:
private HashMap<String, String> emailMap = new HashMap<>();
.
.
.
spinner.setVisibility(View.INVISIBLE);
Map<String, Object> data = new HashMap<>();
data.put("to", emailaddr);
emailMap.clear();
emailMap.put("subject", getString(R.string.post_alert));
emailMap.put("html", getString(R.string.posted_comment) + NL + NL + WEB_APP + url);
data.put("message", emailMap);
emailRef.add(data)
.addOnSuccessListener(new OnSuccessListener<DocumentReference>() {
@Override
public void onSuccess(DocumentReference documentReference) {
spinner.setVisibility(View.INVISIBLE);
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.w(TAG, "Error writing document", e);
Toast.makeText(context, e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
spinner.setVisibility(View.INVISIBLE);
}
});
and, in fact, the document gets created and looks good:
However, the email never gets sent. Looking through the the Google Cloud functions logs, I see the following:
My question is, why is 'message' not a valid object? It looks OK to me.


The problem I was having was due to two errors I made in configuring the Trigger email extension: the SMTP password was missing and I had the name of the email collection wrong.
I got past the problem I originally posted, now I've got a different one: the extension tried to send the email and updated the email document with an error:
Has anyone seen this error before?