Things to watch out for when configuring sendmail. Specially when deploying it for relaying mail for php via your ISP.
Although I thought sendmail was a out-of-box solution for this but I've ran in to this trap so many times that I thought I might as well document it for future, instead of googling everytime.
On debian based distro anyway you just go ahead install sendmail as such.
sudo apt-get install sendmail
Once installed make sure your hostname is correctly configured for that machine. Anything like localhost.localdomain will make sendmail shat itself.
You can always check the log for sendmail to see whats going on.
sudo tail -f /var/log/mail.log
So, open up hostname and hosts file in /etc/
Inside the hosts file make sure it looks something like this
127.0.0.1 localhost
192.168.3.1 yourwebsite.co.nz webserver
Also make sure webserver is the name also mentioned in your hostname file.
Once done that you can restart this service for it to take effect and restart sendmail too.
sudo /etc/init.d/hostname.sh
sudo /etc/init.d/sendmail restart
Now that will hopefully get the ball rolling. If you still having trouble sending mail via php scripts. Then go check the php configuration
sudo locate php.ini
/etc/php5/apache2/php.ini
sudo nano /etc/php5/apache2/php.ini
#CTRL+W then type in sendmail
#Set the sendmail path
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = /usr/sbin/sendmail -t -i
Once you have confirmed that it should be working if still having trouble try doing it manually via telnet
telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 yoursite.co.nz ESMTP Sendmail 8.14.2/8.14.2/Debian-2build1; Thu, 9 Oct 2008 15:43:57 +1300; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]
HELO SENDMAIL
250 aactiveremovals.co.nz Hello localhost [127.0.0.1], pleased to meet you
MAIL FROM:
250 2.1.0 ... Sender ok
RCPT TO:
250 2.1.5 ... Recipient ok
DATA
354 Enter mail, end with "." on a line by itself
TESTING SENDMAIL
.
250 2.0.0 m992jdbX010196 Message accepted for delivery
quit
221 2.0.0 aactiveremovals.co.nz closing connection
Connection closed by foreign host.
Check the log while your doing that too - you will see whats going on. If this process sends an email then that means your sendmail configuraiton is fine.
Another problem I had was php script was taking very long to process forms that send email. Turns out this was due to my DNS resolv.conf file.
Make sure the DNS servers you have are valid, active and in the right order
search 192.168.3.1
nameserver 203.96.152.4
nameserver 192.168.3.1
192.168.3.1 is my DNS server on the local area network. The 203.. one is paradise. Also after reordering or changing the DNS servers youn need to restart sendmail again.
Hoepfully this will help someone running in to sendmail problems.