2

I have a contact form configured on my webpage (made with Flutter web) to send emails automatically with Firebase extension Trigger Email. However, they go directly to the spam folder. I have been reading about the causes why emails go to spam and I don't know if I have any of those. I think authentication (as said here) should not be a problem since the FROM email and the account logged in are the same.

This is the configuration of the extension: enter image description here

And this is an example of an email sent: enter image description here

This is the code to add the document to the firebase collection:

Future<void> _submitForm() async {
    final isValid = _key.currentState?.validate();

    if (isValid != null && isValid) {
      _key.currentState?.save();
      String message;

      try {
        final collection = FirebaseFirestore.instance.collection("mail");
        await collection.doc().set({
          "timestamp": FieldValue.serverTimestamp(),
          "to": ["Name LastName <name.lastname@domain.com>"],
          "message": {
            "subject": _subject,
            "text": "Name: ${_name}\nEmail: ${_email}"
                "\nPhone: ${_phone}\n\n${_message}"
          }
        });

        _key.currentState?.reset();

        message = "Your message has been sent successfully. We will get in "
            "contact with you.";
      } catch (_) {
        message = "Your message could not be sent. Please try again later.";
      }

      ScaffoldMessenger.of(context)
          .showSnackBar(SnackBar(content: Text(message)));
    }
  }

Any idea how could I fix this? Thanks in advance.

General Grievance
  • 4,555
  • 31
  • 31
  • 45
JAgüero
  • 403
  • 1
  • 4
  • 14

0 Answers0