Should I mention in an email to a professor that they are referred by another one?

The letter is fine, but I'd actually suggest that you replace this:

I have asked prof A about studying with him, but he has kindly refer you to me since he's on leave next year.

with something like the following:

Prof A has referred me to you as being a good fit for my research interests.

There is no real need for the rest of it, and might be inferred without saying it directly.

But, your original is fine, also. Good luck.