Spaces:
Running
Running
File size: 4,738 Bytes
7d66a52 3ae5f2d 7d66a52 c8c8672 7d66a52 c8c8672 7d66a52 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import time
import schedule
from functools import partial
import markdown
from datetime import date
DAY_TIME = 60 * 60 * 24
import os
APP_PASSWORD = os.environ['APP_PASSWORD']
def send_email(sender_email, app_password, recipient_email, subject, body):
# Create the email message
msg = MIMEMultipart()
msg['From'] = sender_email
msg['Subject'] = subject
msg['To'] = recipient_email
msg.attach(MIMEText(body, 'html'))
server = smtplib.SMTP_SSL('smtp.gmail.com', 8889)
try:
# Set up the SMTP server
server.starttls() # Secure the connection
server.login(sender_email, app_password) # Log in to your Gmail account
# Send the email
# for recipient_email in recipient_emails:
server.sendmail(sender_email, recipient_email, msg.as_string())
# print("Email sent successfully!" + recipient_email)
except Exception as e:
print(f"Failed to send email: {e}")
finally:
server.quit() # Terminate the SMTP session
def sign_up_email(email, profile):
sender_email = "[email protected]"
app_password = APP_PASSWORD
recipient_email = email
# for recipient_email in email_pool.keys():
email_input = {}
email_input['profile'] = profile
body = \
('''
# Welcome to Arxiv Copilot Monthly Updates!
## Hello,
Thank you for signing up for our monthly update service! We are thrilled to have you on board and look forward to providing you with the latest research topics, ideas, and papers tailored to your interests.
The updates will be sent on 1st of every month at 20:30 (EDT).
---
### π **Your Profile Summary**
{profile}
---
### π **What to Expect**
- Each month, you will receive an email with:
- **Trending Research Topics**: Stay updated on what's popular in your field.
- **Research Ideas**: Get inspired with new ideas tailored to your interests.
- **Recommended Papers**: Discover papers that match your research focus.
Thank you for choosing Arxiv Copilot. We are excited to support your research journey and keep you informed with the latest developments in your field.
Best regards,
**The Arxiv Copilot Team**
---
*If you are unsatisfied with your profile, please edit it at Arxiv Copilot (https://huggingface.co/spaces/ulab-ai/ArxivCopilot) and sign up again!*
''').format_map(email_input)
body = markdown.markdown(body)
# body = MIMEText(body, "html")
subject = "ArxivCopilot Monthly"
send_email(sender_email, app_password, recipient_email, subject, body)
# Example usage
def send_to_users(agent):
if date.today().day != 1:
return
sender_email = "[email protected]"
app_password = APP_PASSWORD
for recipient_email in agent.email_pool.keys():
profile_input = agent.email_pool[recipient_email]
topics, papers, ideas = agent.select_date("month", profile_input)
email_input = {}
email_input['profile'] = profile_input
email_input['topics'] = topics[0]
email_input['ideas'] = ideas[0]
paper_input = ""
for paper in papers.split(';\n'):
paper_input = paper_input + "- " + paper + ";\n"
email_input['papers'] = paper_input
body = \
('''
# Monthly Update from Arxiv Copilot
## Hello,
We are excited to share your personalized monthly update from Arxiv Copilot! Hereβs what we have for you this month:
---
### π **Your Profile Summary**
{profile}
---
### π₯ **Trending Research Topics**
{topics}
---
### π‘ **Research Ideas for You**
{ideas}
---
### π **Recommended Papers**
We have curated a list of papers you might find interesting:
{papers}
Thank you for being a part of Arxiv Copilot. We look forward to supporting your research journey.
Best regards,
**The Arxiv Copilot Team**
---
*If you are unsatisfied with your profile, please edit it at Arxiv Copilot (https://huggingface.co/spaces/ulab-ai/ArxivCopilot) and sign up again!*
''').format_map(email_input)
body = markdown.markdown(body)
subject = "ArxivCopilot Monthly"
send_email(sender_email, app_password, recipient_email, subject, body)
print("sent to"+recipient_email)
def monthlyEmail(agent_ls):
agent = agent_ls[0]
job_with_para = partial(send_to_users, agent)
# schedule.every().minute.do(job_with_para)
# schedule.every().month.do(job_with_para).day.at("00:00")
schedule.every().day.at("20:30", "America/New_York").do(job_with_para)
while True:
schedule.run_pending()
time.sleep(59)
|