Best practice to send emails from AppGyver

Hey guys. I want to send an invitation email from my app on a button click. I wanted to use SendGrid but I am guessing it’s impossible to do so directly from AppGyver due to this:

Is there already a best practice integration or solution for sending email from AppGyver?

Alternatively, does anyone know if SendGrid can be made to work? I tried via HTTP request module but I just receive ‘TypeError: Failed to fetch. Does the server allow CORS?’

Otherwise I guess I have to go refresh my Lambda knowledge and make a request to a Lambda function from AppGyver and make the request to SendGrid from there, right?

Actually, nevermind, I just created an API in Xano which calls Sendgrid instead!

I use Sendgrid directly from Appgyver with no problem with HTTP Request flow function.

Oh really? Is it secure? Maybe you could share a screenshot of your set-up.

Sure!
Here is my simple UI to make an email (with optional attachments):

So what I did was create an Email Object variable with all the fields that SendGrid wants. This one includes attachments field. If there are no attachments then i have another Email Object variable without this field:
Email Object

Here is where I set the values of this Email Object:

So here is the overall flow. It checks if there are attachments or not, because if not then SendGrid doesnt want the attachments field in the email object and I have to send a different Email Object without an attachment field:

Here is how I set Attachments, using the Pick files flow function, convert it to Base64:


And save the output to an attachments List variable:
Page attachments

The HTTP POST request looks like this:

This is the Header part:
Header

And that’s it! It just works like that.

15 Likes

Omg, thank you so much for all the effort of sharing this!

3 Likes

Hi John!

Thank your for sharing this. I had follow these steps and
Can I use free domain email address like Gmail or Yahoo? because SendGrid didn’t allow me to use those mails.

Best regards,
Jaya seelan

Im not sure, ive never tried those domains before.

DO you have a domain?

I use sendgrid with my models.

No, I don’t have any domains.

So it only works with its own domain

John, thanks for posting this, really helpful. Can confirm this still works as of 4/29/2022 :slight_smile:

4 Likes