I have a working django contact page, currently configured to send the mail message to the console, as well as tested with my server. The only issue with using my server settings, is that it uses the pre-configured email in my settings.py to send the message. And I'd like custom email addresses to be entered. I've seen sendgrid is one way of doing this, but I'd like to know if I can achieve this without using a service like sendgrid?

Edit: project code. I'd like for the user to enter their email address in the from\_email field and use my server to send the message instead of using service like sendgrid.

**settings.py**

```py
    EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
    EMAIL_HOST = 'server.domain.tld'
    EMAIL_HOST_USER = 'email@domain.tld'
    EMAIL_HOST_PASSWORD = 'password'
    EMAIL_PORT = 587
    EMAIL_USE_TLS = True

```

**forms.py**

```py

    class ContactForm(forms.Form):
        from_email = forms.EmailField(
            required=True,
            widget=forms.EmailInput(attrs={"placeholder": "Your email address", "class": "heading"}),
            label=''
        )
        subject = forms.CharField(
            required=True,
            widget=forms.TextInput(attrs={"placeholder": "Your subject", "class": "heading"}),
            label=''
        )
        message = forms.CharField(
            required=True,
            widget=forms.Textarea(attrs={"placeholder": "Your message here"}),
            label=''
        )

```

**views.py**

```py

    def contact_page_view(request):
        contact_query = ContactForm(request.POST or None)

        if request.method == 'POST':
            if contact_query.is_valid():
                from_email = contact_query.cleaned_data['from_email']
                subject = contact_query.cleaned_data['subject']
                message = contact_query.cleaned_data['message']

                try:
                    send_mail(subject, message, from_email, ['email@domain.tld'])
                except BadHeaderError:
                    return HttpResponse('Invalid header found.')
                return redirect('pagesapp:confirm')
        return render(request, 'pagesapp/contact.html', {'contact_sub': contact_query})

```

**contact.html**

```html

      <div class="centre form-container centre-pad mobile-pad">
        <form class="article-form" method="POST">
          <h1 class="gold-card">Email Us</h1>
          {% csrf_token %}
          {{contact_sub.as_p}}
          <input type="submit" value="Send email">
        </form>
      </div>

```