I’m stuck trying to set up my Streamlit app in Snowflake to send emails through Gmail. I’ve got a form that lets users pick an email recipient and fill in some details. It works great on streamlit.io, but I want to move it to Snowflake for better security since the data comes from Snowflake tables.
I tried making a network rule to let Snowflake use my Gmail account:
create or replace network rule gmail_access
mode = egress
type = host_port
value_list = ('smtp.gmail.com:465')
;
But I keep getting an error about invalid values for the VALUE_LIST property. I can’t use system$send_email because my recipients aren’t allowed, and even when I am allowed, I don’t get any emails.
Has anyone figured out how to make a Streamlit app in Snowflake send form data via Gmail? I’m completely stuck and could really use some help!
hey there tom, i’ve run into similar issues. have u tried using a third-party email service like SendGrid instead? they’ve got better integration w/ snowflake & less headaches than gmail. might be worth checkin out if ur still stuck. good luck!
I’ve tackled this exact problem before, and it’s a bit tricky. Snowflake’s network rules can be finicky with external services like Gmail. Instead of using Gmail directly, I ended up setting up an AWS SES (Simple Email Service) account and connecting it to Snowflake. It was surprisingly straightforward and solved all my email-sending woes.
The process involves creating an IAM role in AWS, granting Snowflake access to SES, and then using Snowflake’s external functions to send emails. It’s more secure and reliable than trying to use Gmail, and you have more control over the sending process.
If you’re interested, I can share some code snippets or resources that helped me set it up. It might take a bit more initial setup, but it’s definitely worth it for the long-term stability and scalability of your Streamlit app.
I’ve encountered similar challenges with email integration in Snowflake. While Gmail can be problematic, have you considered using Snowflake’s native email functionality? It’s often overlooked, but Snowflake actually has a built-in email service that can be configured for your needs.
To use it, you’ll need to set up an email integration and then use the SYSTEM$SEND_EMAIL function. Here’s a basic example:
CREATE OR REPLACE NOTIFICATION INTEGRATION email_int
TYPE = EMAIL
ENABLED = TRUE;
Then you can send emails like this:
CALL SYSTEM$SEND_EMAIL(
‘email_int’,
‘[email protected]’,
‘Subject’,
‘Email body’
);
This approach bypasses the need for external services and might be more reliable for your Streamlit app. Just ensure you have the necessary permissions set up in your Snowflake account.