Hello
I would like my Streamlit application which is in the cloud to be able to send emails. I still have the same error that occurs:
Erreur lors de l’envoi de l’e-mail : (535, b’5.7.8 Username and Password not accepted. Learn more at\n5.7.8 Check Gmail through other email platforms - Gmail Help 6-20020a170902ee4600b001b9c5e07bc3sm3605362plo.238 - gsmtp’)
I followed and looked up what other people were doing. I do like them. I’ve also looked at google’s documentation on this and I’m good at what to do. I think it’s a Streamlit Cloud problem.
My code:
email_sender = st.text_input(‘sender’)
email_receiver = st.text_input(‘receiver’)
subject = st.text_input(‘subject’)
body = st.text_input(‘body’)
password = st.text_input(‘password’)
if st.button(“Send Email”):
try:
connection=smtplib.SMTP(‘smtp.gmail.com’,587)
connection.starttls()
connection.login(email_sender,password)
message=“Subject:{}\n\n”.format(subject,body)
connection.sendmail(email_sender,email_receiver,message)
connection.quit()
st.succes(‘ok’)
except Exception as e:
st.error(f"Erreur lors de l’envoi de l’e-mail : {e}")
The code is not protected at this time. I am still in the testing phase.
Unfortunately it doesn’t work. I’ve tried just about everything I can find on the forums. The python packages are well installed elsewhere. And I don’t have two-factor authentication enabled. I also followed the recommendations of Google
I fixed the problem with your help. I didn’t have double authentication and I think Google is preventing SMTP connections without double authentication now… I just put double authentication, of course I created a password for the application and everything works perfectly