CarnageOP10 commited on
Commit
76905ee
·
verified ·
1 Parent(s): 535ec0d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -19
app.py CHANGED
@@ -13,40 +13,30 @@ from Gradio_UI import GradioUI
13
 
14
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
15
  @tool
16
- def tool_email_sender(sender:str, pwd:str, reciever:str, subject:str, body:str)-> str:
17
  """Sends an email using SMTP
18
  Args:
19
  sender: Sender's email address
20
  pwd: Sender's email password
21
- reciever: Recipient's email address
22
  subject: Email subject line
23
  body: Main content of the email
24
  """
25
-
26
- SMTP_SERVER = "smtp.gmail.com"
27
  SMTP_PORT = 587
28
- SENDER_EMAIL = sender
29
- RECIEVER_EMAIL = reciever
30
- SENDER_PASSWORD = pwd
31
  try:
32
- # Create message
33
  message = MIMEMultipart()
34
- message["From"] = SENDER_EMAIL
35
- message["To"] = RECIEVER_EMAIL
36
  message["Subject"] = subject
37
-
38
  message.attach(MIMEText(body, "plain"))
39
-
40
  with smtplib.SMTP(SMTP_SERVER, SMTP_PORT) as server:
41
  server.starttls()
42
- server.login(SENDER_EMAIL, SENDER_PASSWORD)
43
-
44
- server.sendmail(SENDER_EMAIL, RECIEVER_EMAIL, message.as_string())
45
-
46
- return f"Email sent successfully to {RECIEVER_EMAIL}"
47
-
48
  except Exception as e:
49
- return f"Unexpected error while sending email: {str(e)}"
50
 
51
 
52
 
 
13
 
14
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
15
  @tool
16
+ def tool_email_sender(sender: str, pwd: str, receiver: str, subject: str, body: str) -> str:
17
  """Sends an email using SMTP
18
  Args:
19
  sender: Sender's email address
20
  pwd: Sender's email password
21
+ receiver: Recipient's email address
22
  subject: Email subject line
23
  body: Main content of the email
24
  """
25
+ SMTP_SERVER = "smtp.gmail.com"
 
26
  SMTP_PORT = 587
 
 
 
27
  try:
 
28
  message = MIMEMultipart()
29
+ message["From"] = sender
30
+ message["To"] = receiver
31
  message["Subject"] = subject
 
32
  message.attach(MIMEText(body, "plain"))
 
33
  with smtplib.SMTP(SMTP_SERVER, SMTP_PORT) as server:
34
  server.starttls()
35
+ server.login(sender, pwd)
36
+ server.sendmail(sender, receiver, message.as_string())
37
+ return f"Email sent successfully to {receiver}"
 
 
 
38
  except Exception as e:
39
+ return f"Error: {str(e)}"
40
 
41
 
42