Example #1
0
def contact(request):
    form = ContactForm(request.POST or None)
    context = {
        'title': 'Contact Us',
        'form': form,
        'title_align_center': True
    }

    if form.is_valid():
        # for key, value in form.cleaned_data.iteritems():
        #     print(key, value)

        form_full_name = form.cleaned_data.get('full_name')
        form_email = form.cleaned_data.get('email')
        form_message = form.cleaned_data.get('message')

        subject = 'Site Contact Form'
        from_email = settings.EMAIL_HOST_USER
        to_email = [from_email, '*****@*****.**']

        contact_message = "%s: %s via %s" % (
            form_full_name, form_message, form_email)

        html_message = "<h1>Hello this message sent from Django Mail via LORDK1 :)) </h1>"
        send_mail(
            subject,
            contact_message,
            from_email,
            to_email,
            html_message=html_message,
            fail_silently=False
        )
        # print(email, full_name, message)

    return render(request, "newsletter/forms.html", context)
Example #2
0
def contact(request):
    form = ContactForm(request.POST or None)

    if form.is_valid():
        email = form.cleaned_data.get('email')
        message = form.cleaned_data.get('message')
        full_name = form.cleaned_data.get('full_name')
        pass

    context = {
        'form': form
    }

    return render(request, 'forms.html', context)
Example #3
0
def newsletter_contact(request):
	form = ContactForm(request.POST or None)
	if form.is_valid():
		email = form.cleaned_data.get("email")
		message = form.cleaned_data.get("message")
		full_name = form.cleaned_data.get("full_name")
		subject = "Django mail test"
		from_email = settings.EMAIL_HOST_USER
		to_email = ["*****@*****.**", "*****@*****.**", "*****@*****.**"]
		contact_message = "This is the body of email. Hi from django application"
		send_mail(subject, contact_message, from_email, to_email, fail_silently=False)

	context = {
		"form": form,
	}
	return render(request, "forms.html", context)
Example #4
0
def contact_page(request):
    welcome_page = WelcomePage.objects.get(id=1)
    categories = CategorySite.objects.all().filter(category__isnull=True).order_by('id')
    eshop_info = EshopInformation.objects.get(id=1)
    if 'search_pro' in request.POST:
        search_text = request.POST.get('search_pro')
        return redirect(reverse('page_results') + '?search_pro=%s'%(search_text))
    if 'contact_form' in request.POST:
        form = ContactForm(request.POST, initial={'date_created':datetime.datetime.now()})
        if form.is_valid():
            form.save()
            messages.success(request, 'Ευχαριστούμε για το μήνυμα μας, θα επικοινωνοίσουμε μαζί σας το συντομότερο δυνατόν')
            return redirect('contact_page')
    else:
        form = ContactForm
    context = locals()
    context.update(csrf(request))
    return render(request, 'obaju/contact.html', context)
Example #5
0
def contact(request):
    title = "Contact Us"
    form = ContactForm(request.POST or None)
    if form.is_valid():
        form_email = form.cleaned_data.get("email")
        form_message = form.cleaned_data.get("message")
        form_full_name = form.cleaned_data.get("full_name")
        form_subject = "Site contact form"
        from_email = settings.EMAIL_HOST_USER
        # to_email = SignUp.objects.filter_by(email=email).all()
        contact_message = "%s: %s via %s" % (form_full_name, form_message, form_email)
        send_mail(
            form_subject,
            contact_message,
            from_email,
            ['*****@*****.**'],
            fail_silently=False,
        )    
    context = {"form": form, "title": title}
    return render(request, "contact.html", context)
Example #6
0
def contact(request):
    title = 'Contact Us'
    form = ContactForm(request.POST or None)
    if form.is_valid():
        form_email = form.cleaned_data.get('email')
        form_message = form.cleaned_data.get('message')
        form_full_name = form.cleaned_data.get('full_name')
        subject = 'Site contact Form'
        from_email = settings.EMAIL_HOST_USER
        to_email = ['*****@*****.**', '*****@*****.**']
        contact_message = '%s : %s via %s' % (form_email, form_message, form_full_name)
        send_mail(subject,
                  contact_message,
                  from_email,
                  to_email,
                  fail_silently=False)

    context = {
        'form': form,
        'title': title,
    }
    return render(request, 'forms.html', context)
Example #7
0
def newsletter_contact(request):
    form = ContactForm(request.POST or None)
    if form.is_valid():
        email = form.cleaned_data.get("email")
        message = form.cleaned_data.get("message")
        full_name = form.cleaned_data.get("full_name")
        subject = "Django mail test"
        from_email = settings.EMAIL_HOST_USER
        to_email = [
            "*****@*****.**", "*****@*****.**", "*****@*****.**"
        ]
        contact_message = "This is the body of email. Hi from django application"
        send_mail(subject,
                  contact_message,
                  from_email,
                  to_email,
                  fail_silently=False)

    context = {
        "form": form,
    }
    return render(request, "forms.html", context)