the server completes the function "mail" in 5 mins

I think it must be a problem with the connection between your web server and your email server. Your email server should be on the same local network or the same machine as the web server.
try using the phpmailer
and directly communicate with the smtp server.
I had the same problem with my localhost...
and resolved using the direct communication with smtp server.