You are right - we can call the Actual Classes as X and Y for Spam and Ham emails respectively.
However, at some point, you will need to assign (actual) probability to each class - 1 and 0.
For Spam, you would assign 1 as you know, for sure, that it is 100% Spam.
For Ham, you would assign 0 as you know, for sure, that it is 0% Spam (and 100% Ham).
Then, you will go ahead with finding the difference between Actual Probability and Predicted Probability (to assess the algorithm's efficiency).
In short, it doesn't matter if you call Spam emails as X and Ham emails as Y. Eventually, you would need to compare actual probability with predicted probability. It's just that when we regard the classes as 1 (Spam) and 0 (Ham), we are skipping a step to comparing Actual Probability with Predicted Probability.
Hope this helps!