Can I use mail function to attach file with message ?

If not .. What is the code that I can use to do that ?