Exemple #1
0
def send_contact_email(request):
    messages = MessagesSystem(request)
    try:
        email_message = f"Email: {request.POST.get('email')} \nMessage: {request.POST.get('message')}"
        send_mail(request.POST.get("subject"), email_message, "",
                  ["*****@*****.**"])
        messages.append_contact("Message was sent!")
    except SMTPException:
        messages.append_contact(
            "Something went wrong! \nPlease try a different method of contact."
        )
Exemple #2
0
 def test_append_contact_messages(self):
     message_system = MessagesSystem(self.request)
     message_system.append_contact("test")
     self.assertEqual(self.request.session.get("contact_messages"),
                      ["test"])