Spaces:
Runtime error
Runtime error
import streamlit as st | |
import smtplib | |
def email_sender(sender_add, password, to_emails, num_emails): | |
for _ in range(num_emails): | |
for to_email in to_emails.split(','): # Split the emails by comma | |
smtp_server=smtplib.SMTP("smtp.outlook.com",587) | |
smtp_server.ehlo() | |
smtp_server.starttls() | |
smtp_server.ehlo() | |
smtp_server.login(sender_add,password) | |
msg_to_be_sent =''' | |
Dear Deans of BAU, | |
#... The rest of your message | |
''' | |
msg_to_be_sent = msg_to_be_sent.encode('utf-8') | |
smtp_server.sendmail(sender_add, to_email.strip(), msg_to_be_sent) | |
smtp_server.quit() | |
return "Emails sent successfully!" | |
def main(): | |
st.title("Email Sender App") | |
sender_email = st.text_input("Your Email") | |
sender_password = st.text_input("Your Email Password") | |
recipient_emails = st.text_input("Recipient Emails (comma separated without space)") | |
num_emails = st.slider("Number of Emails", min_value=1, max_value=10) | |
if st.button('Send Emails'): | |
if sender_email and sender_password and recipient_emails: | |
result = email_sender(sender_email, sender_password, recipient_emails, num_emails) | |
st.success(result) | |
else: | |
st.error('Please fill in all the fields') |