title: How to send email with django "Rest Framwork"?
body: <p>I'm using small Rest api project
  and it works fantastic.</p>
  
  <p>But somehow i have to make send email function in there.</p>
  
  <p>so i added email config in settings.py like that</p>
  
  <p>// settings.py</p>
  
  <pre><code># SMTP Mail service with decouple
  EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
  EMAIL_HOST = "smtp.gmail.com"
  EMAIL_HOST_USER = config('EM_ACCOUNT')
  EMAIL_HOST_PASSWORD = config('EM_PASSWORD')
  EMAIL_PORT = 587
  EMAIL_USE_TLS = True
  DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
  </code></pre>
  
  <p>//views.py</p>
  
  <pre><code>from rest_framework import viewsets
  from consult.models import Consult
  from consult.serializers import ConsultSerializer
  from django.core.mail import EmailMessage
  
  
  class ConsultViewSet(viewsets.ModelViewSet):
      queryset = Consult.objects.all()
      serializer_class = ConsultSerializer
  
  
  def send_email(request):
      email = EmailMessage(
          'Title',
          (ConsultSerializer.name, ConsultSerializer.email, ConsultSerializer.phone),
          'my-email',
          ['my-receive-email']
      )
      email.attach_file(ConsultSerializer.file)
      email.send()
  </code></pre>
  
  <p>// models.py</p>
  
  <pre><code>from django.db import models
  
  
  # Create your models here.
  class Consult(models.Model):
      name = models.CharField(max_length=16)
      position = models.CharField(max_length=16, null=True)
      group = models.CharField(max_length=50)
      email = models.CharField(max_length=50, null=True)
      phone = models.CharField(max_length=14)
      describe = models.TextField(blank=True, null=True)
      file = models.FileField(blank=True, null=True)
      create_date = models.DateTimeField(auto_now_add=True)
      update_date = models.DateTimeField(auto_now=True)
  
      class Meta:
          db_table = 'Consult'
  </code></pre>
  
  <p>// serializers.py</p>
  
  <pre><code>from rest_framework import serializers
  from .models import Consult
  
  
  class ConsultSerializer(serializers.ModelSerializer):
      class Meta:
          model = Consult
          fields = ('id', 'name', 'position', 'group', 'email', 'phone', 'describe', 'file', 'create_date')
  </code></pre>
  
  <p>Yup. that is all of my codes.
  And i setted send_mail function in views.</p>
  
  <p>Honestly I want automatic send mail function 
  when the consult data in my DB. but I can find only normal django explanation.</p>
  
  <p>Can you help me set a automatic send mail function when data created??</p>