Creating a contact form with email notifications for new submissions

I’m creating a fairly simple website that needs to send emails to the site owner every time someone fills out the contact form.

Would it be possible to send email notifications while being able to host everything on the IC and without rigging up a wonky client side solution (basically just recreating a standard contact form experience on the IC)? What’s the best way to accomplish this?

@dpdp I found your ICQS Demo on Github, but wasn’t able to get it up and running on my end. However, it also looks like this would require the separate hosting of an oracle outside of the IC.

@kpeacock I’m a fan! Would you be able to help?


Currently we don’t have an IC way to send outgoing email from a canister. As for a contact form, you’d need to create a custom http_request method to handle the incoming message from the form submission. Check out this thread for implementation details: Question on http_request()

1 Like

Hi Kyle,

Thanks for the reply!

I was able to get a working contact form that can send emails without an oracle. It uses a 3rd party service called EmailJS, which gives the ability to make an API call from the client side without exposing SMTP credentials. It’s not a perfect solution, but it’ll work for now and my client is happy with it!

To test that this would work in production, I deployed a quick and dirty demo you can feel free to play with here:

My client and I are thinking of packaging this contact form solution into a resource for the Dfinity dev community so that other IC websites can have working contact forms. First I’d like to implement a way to store all form submissions in the backend canister so that the information can be recovered if any of the notification emails fail to reach the destination inbox.

Any thoughts or suggestions?

Sounds like a pretty straightforward use case! You could either model the form in your canister, or you can use this example HashMap for JSON-encoded text that I used in one of my example projects!

1 Like