             message.attachments = message.attachments_backup
             message.text = message.content
             delete message.attachments_backup
-        message.mailboxIDs = {}
-        message.mailboxIDs[dest.id] = uidInDest
-        message.date = new Date().toISOString()
-
-        if message.id
-            Message.findPromised message.id
+            message.mailboxIDs = {}
+            message.mailboxIDs[dest.id] = uidInDest
+            message.date = new Date().toISOString()
+
+            if message.id
+                Message.findPromised message.id
                 .then (jdbMessage) ->
                     jdbMessage.updateAttributesPromised message
-        else
-            Message.createPromised message
+            else
+                Message.createPromised message
 
         # attach new binaries
         .tap (jdbMessage) ->


formatMessage = (message) ->
    if message.html?
        message.html = sanitizer.sanitize message.html, (value) ->
            value.toString()

    if not message.text?
        message.text = htmlToText.fromString message.html, htmlToTextOptions


    # find the account and draftBox
    pAccount = pMessage.then (message) ->
        Account.findPromised message.accountID
    .throwIfNull -> new NotFound "Account #{message.accountID}"

    Promise.join pAccount, pMessage, pFiles, (account, message, files) ->
