Exemplo n.º 1
0
 def save(self):
     """
     Sends the message.
     """
     subject = self.get_subject()
     from_email = self.get_from_email()
     email_recipients = self.get_email_recipients()
     context = self.get_context()
     message_body = render_to_string(self.get_template_names(), context)
     try:
         message = mail.EmailMessage(
             subject=subject,
             body=message_body,
             from_email=from_email,
             to=email_recipients,
             headers={
                 'Reply-To': self.cleaned_data['email']
             }
         )
         message.send()
         after_send.send(sender=self.__class__, message=message, form=self)
         logger.info(_("Contact form submitted and sent (from: %s)") %
                     self.cleaned_data['email'])
     except SMTPException:
         logger.exception(_("An error occured while sending the email"))
         return False
     else:
         return True
Exemplo n.º 2
0
 def save(self):
     """
     Sends the message.
     """
     subject = self.get_subject()
     from_email = self.get_from_email()
     email_recipients = self.get_email_recipients()
     context = self.get_context()
     message_body = render_to_string(self.get_template_names(), context)
     try:
         message = mail.EmailMultiAlternatives(
             subject=subject,
             body=message_body,
             from_email=from_email,
             to=email_recipients,
             headers={'Reply-To': self.cleaned_data['email']})
         if settings.USE_HTML_EMAIL:
             html_body = render_to_string(self.html_template_name, context)
             message.attach_alternative(html_body, "text/html")
         message.send()
         after_send.send(sender=self.__class__, message=message, form=self)
         logger.info(
             _("Contact form submitted and sent (from: %s)") %
             self.cleaned_data['email'])
     except SMTPException:
         logger.exception(_("An error occured while sending the email"))
         return False
     else:
         return True
Exemplo n.º 3
0
 def save(self):
     """
     Sends the message.
     """
     subject = self.get_subject()
     from_email = self.get_from_email()
     email_recipients = self.get_email_recipients()
     message_body = self.get_message_body()
     try:
         message = mail.EmailMessage(
             subject=subject,
             body=message_body,
             from_email=from_email,
             to=email_recipients,
             headers={'Reply-To': self.cleaned_data['email']})
         message.send()
         after_send.send(sender=self.__class__, message=message, form=self)
         logger.info(
             _("Contact form submitted and sent (from: %s)") %
             self.cleaned_data['email'])
     except SMTPException:
         logger.exception(_("An error occured while sending the email"))
         return False
     else:
         return True
Exemplo n.º 4
0
    def send_notification(self):
        message_body = render_to_string(self.get_template_names(),
                                        self.get_context())

        try:
            message = mail.EmailMessage(subject=settings.SUBJECT_INTRO +
                                        self.subject,
                                        body=message_body,
                                        from_email=settings.FROM_EMAIL,
                                        to=settings.EMAIL_RECIPIENTS,
                                        headers={'Reply-To': self.email})
            message.send()
            after_send.send(sender=self.__class__, model_instance=self)
            logger.info(
                _("Contact form submitted and sent (from: %s)") % self.email)
        except SMTPException:
            logger.exception(_("An error occured while sending the email"))
            return False
        else:
            return True
Exemplo n.º 5
0
    def send_notification(self):
        message_body = render_to_string(self.get_template_names(), self.get_context())

        try:
            message = mail.EmailMessage(
                subject=settings.SUBJECT_INTRO + self.subject,
                body=message_body,
                from_email=settings.FROM_EMAIL,
                to=settings.EMAIL_RECIPIENTS,
                headers={
                    'Reply-To': self.email
                }
            )
            message.send()
            after_send.send(sender=self.__class__, model_instance=self)
            logger.info(_("Contact form submitted and sent (from: %s)") %
                        self.email)
        except SMTPException:
            logger.exception(_("An error occured while sending the email"))
            return False
        else:
            return True