It’s the same problem with contact forms.
If you look at an email header you get e.g. this:
Subject: user123 has sent you an invite
From: "User123" <[email protected]>
You have to make sure that user names do not resemble values of an email header. If it’s possible for a user to name himself “To: [email protected], [email protected], [email protected], [email protected]” you have to clean the input.
A search for “contact form spam” should show you what to do. You should at least remove all occurrences of "To:", "Subject:", "From:" etc.