There are few things here:
First UI/UX, I would allow the user to fill in the message form fully, subject and message body and only prompt for login on "send". User that are not already logged in should then be prompted to login. Like this the user has already committed time and energy into filling the form, he/she is more likely to login.
From a security perspective there is no difference between ajax and not ajax, a brute force attacker will not go to your page with the form and "click" submit each time, that is way to slow. The attacker will "create" the form programatically without the browser and send it directly to the form's endpoint. So whether the page refreshes or not after form submission is not a factor.
Moreover, you should only have one login method, you can re-use it in different places on your website but it should only be one. There will be only one login point to defend. If there is only one login point then whether the user chooses to login from the home page or from a message submit form will not change anything in terms of security.
you wrote:
I could temporary block an account after X failed login attempts
As you have concluded on your own this probably isn't the best approach.
@lammert answered
If you are afraid of abuse, try implementing tar-pitting.
I haven't header the term tar-pitting, I assume that means progressively slowing the login process. There are many ways to do this, one approach is to simply slow the login process, which makes it annoying for every user. The most common approach I see, is, after one or two failed attempts to show a captcha.
Another way to defend against brute-force attacks, which isn't mutually exclusive with the above, is the ensure that users passwords are long enough and strong enough. You can use a library like zxcvbn. There are versions available for most common languages. Here is a link:
[
github.com...]
I don't know whether or not your are familiar with CSRF attacks:
Attack from "not logged in" users is not the only concern, another type of attack to guard against is CSRF attack (Cross Site Request Forgery). This is where an attacker sends, to a logged in user, a link, typically in the form of an image with an src that is "invalid" in terms of an image but instead points to your endpoint but with a valid uri, thus hijacking the "logged in" users credentials, and in your case sending messages on behalf of that user, without the user's knowledge.