Python - Post senden

// Go to your gmail login 
// Go to ACCOUNT - SECURITY - LESS SECURE - TURN ON 
// You can only see the LESS SECURE option only if you don't have two factor authentication
// so if you have turn it off. 
------------------------------
// views.py inside the APP
// inside # Create your views here.
// def inquiry(request):

from django.core.mail import send_mail
from django.contrib.auth.models import User
from django.core.mail import send_mail

admin_info = User.objects.get(is_superuser=True)
admin_email = admin_info.email
send_mail(
    'New Car Inquiry',
    'You have a new inquiry for the car' + car_title + '. Please login to your admin panel for more info.',
    'active gmail account here ',
    ['admin_email'],
    fail_silently=False,
)

// settings.py 
// email sending
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST_USER = 'active gmail account here'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_PASSWORD = 'email password is here '

// to do the testing go to TERMINAL 
// First is:  
 python manage.py shell 

// Second is: 
 from django.core.mail import send_mail
 
// Third is: 

send_mail('django test mail', 'this is the body', 'active gmail account here', ['active gmail account here'], fail_silently=False)

// if the OUTPUT is 1, then the message sent successfully 
// to to your gamail to check if you received it. 
BenLeolam