you don't need the if() statement and you need some headers.
Try something like:
$toaddress = 'someone@email.com';
$subject = 'the subject';
$message = wordwrap($message, 70);
$message = 'hello,
this is just a test to see if it works';
$headers = 'From: admin@domain.com' . "\r\n" .
'Reply-To: admin@domain.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($toaddress, $subject, $message, $headers);
//rest of the coding here
But if you really want to use the if() statement, here's something I use...that works:
if($settings['notify'] == 1) {
$message="Hello,
This is just a test email to see if my mail is working
Regards,
$settings[admin_name].
";
$headers = "From: $settings[admin_name] <$settings[admin_email]>\n";
$headers .= "Reply-To: $settings[admin_name] <$settings[admin_email]>\n";
mail($settings['admin_email'],'New Email',$message,$headers);
echo "mail sent";
}else{
die('Could not send email.' mysql_error());
}
//rest of the coding here
I have a generic subject so I don't need the $subject and the $toaddress becomes $settings[admin_email]
But I also use a settings.php file which has:
// Send an email to someone? 1=YES, 0=NO
$settings['notify']=1;
// Admin e-mail
$settings['admin_email']='myemail@address.org';
// Admin name
$settings['admin_name']='My name';
Hope that also helps a little more...but a really good tutorial I found is at: http://www.phpbuilder.com/columns/jason_gilmore20050415.php3?aid=883
edit: and if all else fails, do what stolzy said.