sendMail不会从服务器发送电子邮件

So, I have a server set up in Rackspace, which has Apache2 and PHP installed. A web site is hosted there with no problems. The website has a form that sends the information to an email using a php mail() function. The problem is that the sendMailconfig is giving me a problem with the host name. It says:

Warning: local host name app1 is not qualified.

It uses the local host then, but the mail log says that 127.0.0.1 refused the connection, so the mail does not go away. This is my hosts file. I will put xxx on some numbers not to disclose private info:

127.0.0.1 localhost
10.xxx.xxx.247  app1
162.xxx.xxx.164 app1
2001:xxxx:xxxx:xxxxx:xxxx:xxx:3abc app1

If I try to change the name of the host to app1.xxxx.com which is a working domain since the web site is there, it tells me hostname: Name or service not known.

Any ideas why sendmail is not working?