示例#1
0
 def get_pyz_message(self):
     try:
         msg = message_from_string(self.encoded_message)
     except UnicodeEncodeError:
         msg = message_from_string(force_bytes(self.encoded_message))
     except (TypeError, AttributeError):
         msg = message_from_bytes(self.encoded_message)
     return msg
示例#2
0
 def get_pyz_message(self):
     try:
         payload_str = str(self.encoded_message.encode('utf-8'), 'utf-8')
     except TypeError:
         payload_str = self.encoded_message.encode('utf-8')
     msg = message_from_string(payload_str)
     return msg
示例#3
0
 def html_view(self, request, pk):
     msg = models.Message.objects.get(pk=pk)
     payload_str = msg.encoded_message.encode('utf-8')
     msg = message_from_string(payload_str)
     msg_html = msg.html_part.get_payload() if msg.html_part else None
     context = {}
     context['msg_html'] = msg_html
     return render(request, 'django_mailer/html_detail.html', context)
示例#4
0
 def html_view(self, request, pk):
     msg = models.Message.objects.get(pk=pk)
     payload_str = msg.encoded_message.encode('utf-8')
     msg = message_from_string(payload_str)
     msg_html = msg.html_part.get_payload() if msg.html_part else None
     context = {}
     context['msg_html'] = msg_html
     return render(request, 'django_mailer/html_detail.html', context)
示例#5
0
    def get_msg(self, instance):
        try:
            payload_str = str(instance.encoded_message.encode('utf-8'), 'utf-8')
        except TypeError:
            payload_str = instance.encoded_message.encode('utf-8')

        msg = message_from_string(payload_str)
        return msg
示例#6
0
    def get_msg(self, instance):
        try:
            payload_str = str(instance.encoded_message.encode('utf-8'),
                              'utf-8')
        except TypeError:
            payload_str = instance.encoded_message.encode('utf-8')

        msg = message_from_string(payload_str)
        return msg
示例#7
0
 def download_view(self, request, pk, firma):
     payload_str = models.Message.objects.get(
             pk=pk).encoded_message.encode('utf-8')
     msg = message_from_string(payload_str)
     arx = get_attachment(msg, key=firma)
     response = HttpResponse(mimetype=arx.tipus)
     response['Content-Disposition'] = 'filename=' + arx.filename
     response.write(arx.payload)
     return response
示例#8
0
 def download_view(self, request, pk, firma):
     payload_str = models.Message.objects.get(
         pk=pk).encoded_message.encode('utf-8')
     msg = message_from_string(payload_str)
     arx = get_attachment(msg, key=firma)
     response = HttpResponse(mimetype=arx.tipus)
     response['Content-Disposition'] = 'filename=' + arx.filename
     response.write(arx.payload)
     return response
示例#9
0
 def detail_view(self, request, pk):
     instance = models.Message.objects.get(pk=pk)
     payload_str = instance.encoded_message.encode('utf-8')
     msg = message_from_string(payload_str)
     context = {}
     context['subject'] = msg.get_subject()
     context['from'] = msg.get_address('from')
     context['to'] = msg.get_addresses('to')
     context['cc'] = msg.get_addresses('cc')
     msg_text = msg.text_part.get_payload() if msg.text_part else None
     msg_html = msg.html_part.get_payload() if msg.html_part else None
     context['msg_html'] = msg_html
     context['msg_text'] = msg_text
     context['attachments'] = get_attachments(msg)
     context['is_popup'] = True
     context['object'] = instance
     return render(request, 'django_mailer/message_detail.html', context)
示例#10
0
 def detail_view(self, request, pk):
     instance = models.Message.objects.get(pk=pk)
     payload_str = instance.encoded_message.encode('utf-8')
     msg = message_from_string(payload_str)
     context = {}
     context['subject'] = msg.get_subject()
     context['from'] = msg.get_address('from')
     context['to'] = msg.get_addresses('to')
     context['cc'] = msg.get_addresses('cc')
     msg_text = msg.text_part.get_payload() if msg.text_part else None
     msg_html = msg.html_part.get_payload() if msg.html_part else None
     context['msg_html'] = msg_html
     context['msg_text'] = msg_text
     context['attachments'] = get_attachments(msg)
     context['is_popup'] = True
     context['object'] = instance
     return render(request, 'django_mailer/message_detail.html', context)
示例#11
0
 def get_pyz_message(self):
     try:
         msg = message_from_string(self.encoded_message)
     except (TypeError, AttributeError):
         msg = message_from_bytes(self.encoded_message)
     return msg