first commit
This commit is contained in:
40
contact/tasks.py
Normal file
40
contact/tasks.py
Normal file
@@ -0,0 +1,40 @@
|
||||
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)}"
|
||||
|
||||
Reference in New Issue
Block a user