Files
atabackend/contact/tasks.py
Beyhan Oğur d50f14bcb1 first commit
2026-04-26 22:20:45 +03:00

41 lines
962 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from celery import shared_task
from django.core.mail import send_mail
from django.conf import settings
@shared_task
def send_contact_email(name, email, subject, message, ip=None):
"""
Contact formundan gelen mesajı email ile gönderir
"""
email_subject = f"Yeni İletişim Mesajı: {subject}"
email_message = f"""
Yeni bir iletişim mesajı alındı!
Gönderen: {name}
Email: {email}
IP Adresi: {ip or 'Belirtilmemiş'}
Konu: {subject}
Mesaj:
{message}
---
Bu mesaj otomatik olarak gönderilmiştir.
"""
try:
send_mail(
subject=email_subject,
message=email_message,
from_email=settings.DEFAULT_FROM_EMAIL,
recipient_list=['info@denizogur.com.tr'], # Mesajların gönderileceği email adresi
fail_silently=False,
)
return f"Email başarıyla gönderildi: {email}"
except Exception as e:
return f"Email gönderilemedi: {str(e)}"