as you know to sign a message the sender must first of all calculate the hash of the message and then encrypte it using his private key
Actually, in general, that's not how signature algorithms work. Some can be described that way (if you don't look too closely), but others work entirely differently.
What you can more correctly say is that the signature generation algorithm takes the message and the private key, and produces a signature; the signature verification algorithm takes a message, a putative signature and the public key, and says whether the signature was generated by the message/private key. And (here's the important part for your question) the public key doesn't allow you to do anything else
so how the reciver got the public key
There are a number of ways; the most common is that the sender sends the public key, along with proof that this public key corresponds to the sender's identity; this is essentially what a certificate is.
if the sender send it to the reciver that woudn't be dangeuros the key is known by a hacker for instance
No, it's not dangerous at all - remember the part I emboldened above - the public key allows you to verify signatures, but doesn't allow anything beyond that. Yes, this allow the hacker to also verify signatures - we don't care about that.