An error occurred while moving messages to mailbox “(null)”

Try selecting the Trash mailbox (folder) and then the menu item:

MailboxUse This Mailbox AsTrash Mailbox


If this is occurring with a Gmail IMAP account:

This problem occurred for me because my Trash label in gmail was not set to 'show in IMAP' (despite following the recommendation of @rcarver). I required one additional step first, i.e.

  1. In Gmail settings, make sure that the trash label is set to 'show' and 'Show in IMAP'.

  2. In Mail.app, select the trash folder, Mailbox → Use This Mailbox As → Trash Mailbox.
    [see @rcarver's answer above]