create email sender function
This commit is contained in:
@@ -10,12 +10,14 @@ from django.core.exceptions import ValidationError
|
||||
from django.db import models
|
||||
from django.db.models import Q
|
||||
|
||||
from .serializers import RouteSerializer, CreateRouteSerializer, CitySerializer, CountrySerializer, PlanChangeSerializer, PricingSerializer, LeadSerializer, LeadResponseSerializer
|
||||
from api.auth.serializers import UserResponseSerializer
|
||||
from api.models import UserProfile
|
||||
from api.utils.decorators import handle_exceptions
|
||||
from routes.models import Route, City, Country, Leads
|
||||
from sitemanagement.models import Pricing
|
||||
from .serializers import RouteSerializer, CreateRouteSerializer, CitySerializer, CountrySerializer, PlanChangeSerializer, PricingSerializer, LeadSerializer, LeadResponseSerializer
|
||||
|
||||
from api.utils.decorators import handle_exceptions
|
||||
from api.utils.emailSender import send_email
|
||||
|
||||
class UserDataView(ViewSet):
|
||||
"""Эндпоинт для наполнения стора фронта данными"""
|
||||
@@ -244,6 +246,18 @@ class LeadViewSet(ViewSet):
|
||||
"moving_date": lead.moving_date,
|
||||
}
|
||||
}
|
||||
|
||||
# Тестовая отправка email
|
||||
try:
|
||||
email_result = send_email(
|
||||
to=["timofey.syr1704@yandex.by"],
|
||||
subject="Тестовое письмо от TripWB",
|
||||
html_content="<h1>Тест отправки письма</h1><p>Если вы видите это сообщение, значит отправка работает!</p>"
|
||||
)
|
||||
print(f"Email sending result: {email_result}")
|
||||
except Exception as email_error:
|
||||
print(f"Error sending email: {str(email_error)}")
|
||||
|
||||
return Response(response_data, status=status.HTTP_201_CREATED)
|
||||
except Exception as e:
|
||||
return Response(
|
||||
|
||||
Reference in New Issue
Block a user