import webbrowser import urllib.parse from typing import List def send_email( llm_text: str, recipients: str = "", subject: str = "", email_wrapping_content: str = "", ): """Send an email to the specified recipients. Args: recipients (List[str], optional): List of email addresses. Defaults to [""]. subject (str): Subject of the email. email_content (_type_): Content of the email. Example usage: - send_email("test@example.com;test2@example.com", "Hello!", "This is the body of the email.") """ recipients_list = recipients.split(";") email_addresses = ",".join([recipient.strip() for recipient in recipients_list]) # URL encode the subject and email content to ensure it's correctly parsed subject = urllib.parse.quote(subject) if "" in email_wrapping_content: email_content = email_wrapping_content.replace("", llm_text) else: email_content = email_wrapping_content + "\n\n" + llm_text email_content = urllib.parse.quote(email_content) # Construct the mailto URL mailto_url = f"mailto:{email_addresses}?subject={subject}&body={email_content}" # Open the default email client webbrowser.open(mailto_url, new=2)