I might be confusing you a little.
I was using minkoko's last code as an example. I also never tested it but can see at second glance the
PHP Code:
mail($to,$name,$message,$headers);
if(mail)
{
echo "Mail Sent.";
}
else
{
echo "Cannot Send your mail for error";
}
should read
PHP Code:
if(mail($to,$name,$message,$headers))
{
echo "Mail Sent.";
}
else
{
echo "Cannot Send your mail for error";
}
The code I added to it is there to give you a simple example of setting errors and stopping the script calling the "mail" function if there are errors.
That should help point you in the right direction