code: def store_mail(mbx, mail):
          
          if not isinstance(mbx, mailbox.Mailbox):
              logging.debug('Not a mailbox')
              return False
  
          mbx.lock()
          if isinstance(mbx, mailbox.Maildir):
              logging.debug('Maildir')
              msg = mailbox.MaildirMessage(mail)
              msg.set_flags('S')
          else:
              logging.debug('no Maildir')
              msg = mailbox.Message(mail)
  
          try:
              message_id = mbx.add(msg)
              mbx.flush()
              mbx.unlock()
              logging.debug('got mailbox msg id : %s', message_id)
          except Exception as e:
              raise StoreMailError(e)
  
          path = None
          # add new Maildir message to index and add tags
          if isinstance(mbx, mailbox.Maildir):
              # this is a dirty hack to get the path to the newly added file
              # I wish the mailbox module were more helpful...
              plist = glob.glob1(os.path.join(mbx._path, 'new'),
                                 message_id + '*')
              if plist:
                  path = os.path.join(mbx._path, 'new', plist[0])
                  logging.debug('path of saved msg: %s', path)
          return path
docs: stores given mail in mailbox. If mailbox is maildir, set the S-flag and
          return path to newly added mail. Oherwise this will return `None`.
  
          :param mbx: mailbox to use
          :type mbx: :class:`mailbox.Mailbox`
          :param mail: the mail to store
          :type mail: :class:`email.message.Message` or str
          :returns: absolute path of mail-file for Maildir or None if mail was
                    successfully stored
          :rtype: str or None
          :raises: StoreMailError