<reponame>diz-daniel/django-softy-pinko<gh_stars>0
from django import forms
from django.core.mail.message import EmailMessage


class ContactUsForm(forms.Form):
    name = forms.CharField(label='Name', max_length=200)
    email = forms.EmailField(label='E-mail', max_length=200)
    message = forms.CharField(label='Message', widget=forms.Textarea)

    def send_email(self):
        name = self.cleaned_data['name']
        email = self.cleaned_data['email']
        message = self.cleaned_data['message']

        body = f"""
        Sent by: {name}
        Reply-To: {email}
        
        ******************** Message ******************** 
        {message}
        """

        email = EmailMessage(
            body=body,
            from_email='<EMAIL>',
            to=['<EMAIL>', '<EMAIL>', ],
            headers={'Reply-To': email}
        )
        email.send()


from django import forms
from django.core.mail.message import EmailMessage


class ContactUsForm(forms.Form):
    name = forms.CharField(label='Name', max_length=200)
    email = forms.EmailField(label='E-mail', max_length=200)
    message = forms.CharField(label='Message', widget=forms.Textarea)

    def send_email(self):
        name = self.cleaned_data['name']
        email = self.cleaned_data['email']
        message = self.cleaned_data['message']

        body = f"""
        Sent by: {name}
        Reply-To: {email}
        
        ******************** Message ******************** 
        {message}
        """

        email = EmailMessage(
            body=body,
            from_email='<EMAIL>',
            to=['<EMAIL>', '<EMAIL>', ],
            headers={'Reply-To': email}
        )
        email.send()
Sent by: {name}         Reply-To: {email}                  ******************** Message ********************          {message}