This question has been asked before in reference to 2D. This question extends it to 3D. How do I find the perpendicular intersected point on a line from a point in 3D space?
You're asking, in practice, the calculation of a distance between the point and line, so the Length of the vector from the (x3,y3,z3) point to the line which is orthogonal to the vector. If we immagine the line like a vector, that means that dot-product of both vectors is equal to 0. (this is just to give you a hint) .