Characterization of Compact Space via Continuous Function Let $(X,\mathfrak{T})$ be a topological space. We know that if $X$ is compact and $f:X\to \mathbb{R}$ be any continuous function then $f(X)$ is bounded since the continuous image of a compact set is compact and any compact subset of a metric space is bounded.
My questions are (edited after David C. Ullrich's comment below),


What is(are) the necessary and/or sufficient condition(s) on  $(X,\mathfrak{T})$ so that if for any continuous $f:X\to \mathbb{R}$ we can conclude that $f(X)$ is bounded then it would imply that $X$ is compact?

Let $(X,\mathfrak{T})$ be a topological space. If every continuous function $f:X\to Y$ is bounded for all metric space $(Y,d)$  then can we say that $X$ is compact?

Let $(X,\mathfrak{T})$ be a topological space. If there exists a metric space $(Y,d)$ such that every continuous function $f:X\to Y$ is bounded  then can we say that $X$ is compact?
A space $X$ is called pseudocompact when every real-valued continuous function on $X$ is bounded. This is a well-studied notion. Indeed a compact space, or even a countably compact space (every countable open cover has a finite subcover) is pseudocompact. 

A classical theorem: for normal and $T_1$ spaces, countably compact and pseudocompact are equivalent. 

The classical example of $\omega_1$, the first uncountable ordinal, is pseudocompact (and countably compact) and not compact. This shows that we cannot make the jump from countably compact to compact. 

We can use Lindelöf (every cover has a countable subcover) as the gap property to compactness. So if we use at least Tychonoff spaces, a class of spaces where pseudocompactness and compactness coincide are the Lindelöf spaces.

Another class are the metric spaces, because for metric spaces countable compactness, pseudocompactness and compactness are equivalent.

A pseudocompact space has the property that every continuous map into every metric space is bounded. This follows from the equivalence for metric spaces and the fact that the continuous image of a pseudocompact space is pseudocompact.

So $\omega_1$ is also a counterexample to question 2, and a fortiori to 3 as well.
Let's say a space is RB if every continuous real-valued function is bounded.

You ask for necessary and sufficient conditions such that RB implies compact. The word "implies" is a little funny; what people often mean by it is difficult if not impossible to define precisely.

The only precise definition of "A implies B" that I know is "A is false or B is true". If we take that as the definition of "implies" then the answer to your question is that RB implies compact if and only if $X$ is compact or there exists an unbounded real-valued continuous function on $X$.

Almost surely not an answer to what you really wanted to know, but possibly the best answer that question is going to get. (The best answer that actually gives a necessary and sufficient condition.)