Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import smtplib
|
3 |
+
|
4 |
+
def email_sender(sender_add, password, to_emails, num_emails):
|
5 |
+
|
6 |
+
for _ in range(num_emails):
|
7 |
+
for to_email in to_emails.split(','): # Split the emails by comma
|
8 |
+
smtp_server=smtplib.SMTP("smtp.outlook.com",587)
|
9 |
+
smtp_server.ehlo()
|
10 |
+
smtp_server.starttls()
|
11 |
+
smtp_server.ehlo()
|
12 |
+
smtp_server.login(sender_add,password)
|
13 |
+
|
14 |
+
msg_to_be_sent ='''
|
15 |
+
Dear Deans of BAU,
|
16 |
+
#... The rest of your message
|
17 |
+
'''
|
18 |
+
|
19 |
+
msg_to_be_sent = msg_to_be_sent.encode('utf-8')
|
20 |
+
smtp_server.sendmail(sender_add, to_email.strip(), msg_to_be_sent)
|
21 |
+
|
22 |
+
smtp_server.quit()
|
23 |
+
return "Emails sent successfully!"
|
24 |
+
|
25 |
+
def main():
|
26 |
+
st.title("Email Sender App")
|
27 |
+
sender_email = st.text_input("Your Email", type='email')
|
28 |
+
sender_password = st.text_input("Your Email Password", type="password")
|
29 |
+
recipient_emails = st.text_input("Recipient Emails (comma separated without space)")
|
30 |
+
num_emails = st.slider("Number of Emails", min_value=1, max_value=10)
|
31 |
+
|
32 |
+
if st.button('Send Emails'):
|
33 |
+
if sender_email and sender_password and recipient_emails:
|
34 |
+
result = email_sender(sender_email, sender_password, recipient_emails, num_emails)
|
35 |
+
st.success(result)
|
36 |
+
else:
|
37 |
+
st.error('Please fill in all the fields')
|
38 |
+
|
39 |
+
if __name__ == "__main__":
|
40 |
+
main()
|