How can I close the mail function in terminal? Every time I open the Terminal.app, it shows You have new mail. I want to know, how it is caused and how can I close the mail function.

I do not wish to see any mails and the above message when I launch the Terminal.app.
To read the mail you have, use the mail command. man mail will give you instructions.

To delete all mail without reading it, run

sudo rm /var/mail/$USER/*