Contact form data (using Wagtail's formbuilder) is not sending to email what is the issue?
I added email host also but not sending data to email
The form response (contact data) is being saved in wagtail admin but data not sending to email.
Console Output
DEBUG CONSOLE
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: contact form submission
From: archanapco8@gmail.com
To: ranjuranjitha. 1997@gmail.com
Date: Mon, 08 Nov 2021 08:13:45 -0000
Message-ID: <163635922547.9304.15785246130187863651@DESKTOP-NC1TOGR>
Auto-submitted: auto-generated
Your Name: ranjitha
Your company: mdrift
Your email address: rmanju@dgmail.com
When do you want to start?: 20-09-2021
What is your budget: 1000
Describe your needs, the more we know, the better: hi
[08/Nov/2021 13:43:45] "POST /contact-us/ HTTP/1.1" 200 9590
[08/Nov/2021 13:43:45] "GET /static/img/Thank-you.png HTTP/1.1" 200 15470
O
contact/models.py
from wagtail.contrib.forms.models import AbstractEmailForm, AbstractFormField
class FormField(AbstractFormField):
page = ParentalKey('Form Page', related_name='custom_form_fields')
class Form Page(AbstractEmailForm):
thank_you_text = RichTextField(blank=True)
content_panels = AbstractEmailForm.content_panels + [
InlinePanel('custom_form_fields', label="Form fields"),
FieldPanel('thank_you_text', classname="full"),
MultiFieldPanel([
FieldRowPanel([
FieldPanel('from_address', classname="col6"),
FieldPanel('to_address', classname="col6"),
]),
FieldPanel('subject'),
], "Email Notification Config"),
]
def get_form_fields(self):
return self.custom_form_fields.all()
form_page.html
{% load static wagtailcore_tags widget_tweaks %}
{% block content %}
<h1>Contact</h1>
<br>
<form action="{% pageurl page %}" method="POST">
{% csrf_token %}
{% if form.non_field_errors %}
<div class="alert alert-danger" role="alert">
{% for error in form.non_field_errors %}
{{ error }}
{% endfor %}
</div>
{% endif %}
{% for field in form.visible_fields %}
<div class="form-group">
{{ field.label_tag }}
{% render_field field class+="form-control" %}
</div>
{% endfor %}
<button type="submit" class="btn btn-primary" >Submit</button>
</form>
{% endblock %}
settings/base.py
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'ranjuranjitha.1997@gmail.com'
EMAIL_HOST_PASSWORD = 'Password$'
EMAIL_USE_TLS = True
EMAIL_USE_SSL = True
DEFAULT_FROM_EMAIL ='ranjuranjitha.1997@gmail.com'
EMAIL_TO = 'ap8366106@gmail.com'
This is dev.py file. I given email backend also but not sending the mail.
settings/dev.py
from .base import *
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-iu22rfee4za6ro+mez!4*@_trpy7!ebpbtu8iw$95v(rh_5fib'
# SECURITY WARNING: define the correct hosts in production!
ALLOWED_HOSTS = ['*']
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
try:
from .local import *
except ImportError:
pass