I’m working on an app in which I need to send emails at intervals. I’m using python’s smtplib. When I host the app locally, I have no issues, but when it’s deployed, I run into mysterious problems: Everything seems to go smoothly - the logs say the email has sent, no exceptions, I’ve even set smtplib’s log level to debug and can see that the entire SMTP client-server communication seems to be successful - but the emails never arrive. I think I’ve controlled for all other differences: same sender/receiver, same data being sent, etc. The only difference is where it’s hosted. Here’s an example of a minimal email app that causes me issues: https://minimal.streamlit.app/. Run locally, I receive the emails; hosted, I do not - identical in the logs. Any ideas? This may not properly be a streamlit-responsible issue, but I wondered if anyone else has had a similar problem when using streamlit.
There’s similar post on the use of smtplib for sending emails from a Streamlit app along with a solution that has a code snippet by my colleague @tonykip that you can use:
Thank you! I had seen this post, and I don’t believe it’s relevant to the particular issue I’m having. The emails send just fine from a local instance (just not from the deployment on streamlit cloud) and this is a private mail server which doesn’t have any multifactor authentication or any such thing. All passwords etc. are set up the same locally and in the deployment. I was wondering if perhaps streamlit cloud is being blocked in some way from sending requests to send emails (although, like I said, the smtplib logs don’t suggest that). Is streamlit ever blacklisted in any way that you know of?
It seems to me that it has to do with our private mail server. My guess is that it is somehow flagging streamlit-hosted apps as insecure. I’m not sure why no errors are thrown, but seeing as how it works when deployed locally and I’ve exhausted implementation options, I think I’ll just have to either host a new mail server that I have more fine-grained control over or host my streamlit app elsewhere.
Thank you for providing the details of your implementation. Please let us know if you find a better solution to this as am sure somebody will ask this in future.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.