this is send email function:
import os

from loguru import logger
import yagmail


def send_email(subject, content, recipient_email, attachment_file=None):
    # Set up the email credentials
    sender_email = os.environ.get('SENDER_EMAIL')
    sender_password = os.environ.get('SENDER_PASSWORD')

    if not send_email or not sender_password:
        raise ValueError("Email credentials not provided.")
    # Create a yagmail object
    yag = yagmail.SMTP(user=sender_email, password=sender_password)

    # Send the email
    try:
        yag.send(
            to=recipient_email,
            subject=subject,
            contents=content,
            attachments=attachment_file,
            )
        logger.success("Email sent successfully!")
    
    except Exception as e:
        logger.error(f"Error sending email: {e}")
        return False
    
    else:
        return True

    finally:
        # Close the yagmail object
        if 'yag' in locals():
            yag.close()



and this is streamlit code for send email:

import streamlit as st
from src.utils.db import DataBaseManager
from datetime import datetime
from src.utils.send_email import send_email


def main():
    st.title("Send Email 📧")
    st.write("Compose and send emails to your contacts.")

    db_manager = DataBaseManager()

    # Select contacts
    contacts = db_manager.list_contact_profiles()
    if contacts:
        contact_options = [f"{c['name']} ({c['email']})" for c in contacts]
        selected_contacts = st.multiselect("Select Recipients", contact_options)
        recipient_emails = [c.split('(')[-1][:-1] for c in selected_contacts]
    else:
        st.info("No contacts available.")
        recipient_emails = []

    # Select or write an email template
    templates = db_manager.list_templates()
    use_template = st.checkbox("Use an email template")

    if use_template and templates:
        template_titles = [t['title'] for t in templates]
        selected_template_title = st.selectbox("Select a Template", template_titles)
        selected_template = next((t for t in templates if t['title'] == selected_template_title), None)
        subject = selected_template['subject']
        body = selected_template['body']
    else:
        subject = st.text_input("Subject")
        body = st.text_area("Body")

    # Schedule the email
    schedule_time = st.date_input("Schedule Date", datetime.now())
    schedule_time_full = st.time_input("Schedule Time", datetime.now())

    # Combine date and time
    scheduled_datetime = datetime.combine(schedule_time, schedule_time_full)

    if st.button("Send Email"):
        if recipient_emails and subject and body:
            # You need to implement actual email sending functionality
            # For now, we'll assume the email is scheduled
            email_data = {
                'to': recipient_emails,
                'subject': subject,
                'body': body,
                'sent_at': scheduled_datetime.isoformat()
            }
            db_manager.add_sent_email(email_data)
            st.success(f"Email scheduled to be sent to {', '.join(recipient_emails)} at {scheduled_datetime}.")
        else:
            st.error("Please provide recipients, subject, and body.")

if __name__ == "__main__":
    main()


please use send_email function in streamlit code