I am about to fail a required course due to difficulties caused by mental health issues. How can I save my degree?
First, the most important thing is to improve your mental health. Without taking the time to recover from this illness, these sorts of professional problems are likely to recur, even if you overcome this current situation. So, two suggestions:

Begin (or continue) working with a mental health professional. In addition to the obvious medical benefits, this will give you some firm documentation of the problem, which could be helpful academically.
Talk to your someone within your program -- either the graduate director or another trusted professor or someone in the school's counseling center. They can help you assess your academic options -- for example, the option of taking a leave of absence while you recover.


Therefore, I was thinking of reaching out to my professor by email and explaining to him all what I was going through and asking him if it is possible that he gives me some work to do or something to pass the course.

I do not recommend this. I received these sort of requests at the end of every class I taught, and my response was always along the lines of &quot;Too late, the course is over. It wouldn't be fair to the other students if I changed the grading scheme at this late time.&quot; While some instructors might be less hard-hearted than me, I think very few would be willing to give extra points for no reason, or to allow &quot;extra credit&quot; for one student only.
That said, there is still some hope -- if a student missed a passing mark by just a few percent, I would occasionally &quot;round up&quot; and award the passing grade. I would do this for every class, regardless of whether the students had e-mailed me with supplications.

Is there another way to save the situation?

I would approach this from the other side -- see my second bullet above. The graduate director, or your school's mental health office, might be able to arrange for an exception, or a leave of absence, or some other work around.