Ticket #31460: copy.diff

File copy.diff, 897 bytes (added by Samyak Gaur, 5 years ago)
  • django/core/mail/message.py

    diff --git a/django/core/mail/message.py b/django/core/mail/message.py
    index 656c41d63b..eba57cbf7b 100644
    a b  
    11import mimetypes
    2 
     2import imaplib, time
    33from email import (
    44    charset as Charset, encoders as Encoders, generator, message_from_string,
    55)
    class EmailMessage:  
    397397                value = ', '.join(str(v) for v in values)
    398398            msg[header] = value
    399399
     400    def copy(self):
     401        """
     402        makes a copy of the email in sender's sent folder
     403        """
     404        message = str(self.message())
     405        imap = imaplib.IMAP4(settings.EMAIL_HOST)
     406        imap.starttls()
     407        imap.login(settings.EMAIL_HOST_USER, settings.EMAIL_HOST_PASSWORD)
     408        imap.append('INBOX.Sent', '\\SEEN', imaplib.Time2Internaldate(time.time()), message.encode()) 
     409        imap.logout()
Back to Top