from django.core.mail import send_mail
from django.conf import settings

def send_contact_message(name, email, message):
    """Sends an email from the contact form."""
    try:
        subject = f'Contact Form Message from {name}'
        message_body = f'You have received a new message from your website contact form.\n\n' \
                       f'Here are the details:\n\n' \
                       f'Name: {name}\n' \
                       f'Email: {email}\n\n' \
                       f'Message:\n{message}\n'
        
        send_mail(
            subject,
            message_body,
            settings.DEFAULT_FROM_EMAIL, # from
            [settings.CONTACT_EMAIL_TO], # to
            fail_silently=False,
        )
        return True
    except Exception as e:
        # In a real app, you'd want to log this error
        print(e)
        return False
