import logging
from aiva.email.throttle_manager import ThrottleManager

logger = logging.getLogger(__name__)

class EmailSender:
    def __init__(self, throttle_manager: ThrottleManager):
        self.throttle_manager = throttle_manager

    def send_email(self, recipient: str, subject: str, body: str) -> bool:
        """Sends an email to the specified recipient.

        Args:
            recipient: The email address of the recipient.
            subject: The subject of the email.
            body: The body of the email.

        Returns:
            True if the email was sent successfully, False otherwise.
        """
        domain = recipient.split('@')[1]

        if not self.throttle_manager.allow_email(domain):
            logger.warning(f"Email throttled for domain: {domain} to {recipient}")
            # Implement configurable queuing or dropping here
            # For now, we're simply dropping the email
            return False

        # Simulate sending the email (replace with actual email sending logic)
        print(f"Sending email to: {recipient}, subject: {subject}")
        logger.info(f"Email sent to: {recipient}, subject: {subject}")

        return True