Hi there, and thank you for reaching out with your question regarding your mental health and the future of your friendship with your close female friend. In your question, you seem to wonder how you can preserve this friendship with her after her marriage, and how you can work on your mental health in the face of this uncertainty.
There are some ambiguities in your message which makes it difficult to be very specific about the situation. For instance, you state that you became "attached" to her - this could mean a deep emotional connection, or a romantic attraction, or both. From the tone of your message I assume there was something romantic there perhaps, especially given your concern that her husband may not "allow" her to stay in contact with you (I'm also not sure of whether you are male or female, which may also be of importance in this situation). You also say she stopped talking to you after the engagement as she knew of your "condition" - does this mean she was aware you were attracted to her and therefore broke off the friendship to spare your feelings? If so, it could be that she wishes to set a boundary with you as she may feel it would be unfair and inappropriate of her to continue a friendship with someone who has an attraction to her, as well as being difficult to manage possibly further down the line. You can't force someone to want to stay friends with you, and oftentimes it's better to say goodbye and let go gracefully.
First of all, it would be wise to consider what is best for yourself in this situation. Your friend sounds like she is settled and moving on with another part of her life, so now is a great time for you to think about what you want. You say you want to maintain a healthy friendship with her, but you are frightened of losing her. Think about why it is that you're so frightened of losing her - what would this mean to you, if you did lose her? What does this person symbolize to you? Perhaps you felt that there could be a romantic connection between you, which has now become impossible, and this is a sad, hurt feeling for you, possibly a feeling of rejected or being abandoned. Maybe you feel not good enough. Or possibly, you two were very close and you shared things together, and there are not many other people in your life who you have this connection with, and you are mourning the loss of this closeness. You say she is always on your mind, and it must be very difficult and distressing for you to be feeling this level of anxiety and concern about her, and worrying about what the future of your friendship will look like - if there will be a future. You say that in your heart you want closure, but what does this mean? It is not always possible to have the perfect continuation of a friendship, and she may not wish for it either. You will not be able to control how she feels about you or the friendship, and, if you feel very distressed about this, it may not be wise for you to try to cling to this friendship. Think about how you will feel if she becomes more distant, should she have children or become more involved in her new life. It is better for you to focus on yourself, rather than her.
As such, in order to maintain good mental health, the wisest course of action would be to let go of the attachment to her by building up other areas of your life. If you are feeling lonely and bereft without her, now is the time to start forming new friendships and possibly looking into dating other people. You can pour time and energy into other projects, career, socializing, family or hobbies, and this will take your mind off of your friend, while also giving you the chance to find happiness and satisfaction elsewhere. Honor the friendship for what it was, rather than wishing things were different. If your friend does want to stay in contact, then you can see how you feel about this, and it will become a bonus in your life rather than a necessity.
I hope this answer is helpful to you and I wish you all the best for the future.