'when i submit email form it send back my own email Django python

class ProjectListAndFormView(SuccessMessageMixin, ListView, FormView):
model = Project # data from database
template_name = 'mainpage/main.html'
context_object_name = 'list_projects' # name of the var in html template
queryset = Project.objects.all().order_by("-pub_date")#  list of all projects
object_list = None

form_class = ContactForm
success_url = '/' # After submiting the form keep staying on the same url
success_message = 'Your Form has been successfully submitted!'

def form_valid(self, form):
    # This method is called when valid form data has been POSTed.
    cd = form.cleaned_data
    con = get_connection('django.core.mail.backends.console.EmailBackend')
    send_mail(
        cd['name'],
        cd['message'],
        cd.get('email', '[email protected]'),
        ['[email protected]'],
        fail_silently=False
    )
    return super(ProjectListAndFormView, self).form_valid(form)

views.py

im having trouble with a form page on my website. Whenever i enter a random email on the email form part on the website it sends a succesful mail but from my own emayil even if i put a random email. How do i fix this so when someone enters their email, it sucesfully sends me an email from their email?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source