PHP e-mail not working

I have an e-mail form that I am trying to test out…but nothing happens when I click the send mail button…after searching online for some time, I have found several “test” php files which are supposed to test whether my server allows e-mail…but I cannot figure out how to execute these test pages…all the sites say is to change the e-mail to reflect my domain, and upload to the server…and open the php file in a web browser…

When I try this, I get “The page cannot be found” HTTP 404 error…any ideas as to why? Is this because e-mail is disabled on my server?


<?php 
    //This is just a test script to check if the server can send an email. 
    //Upload this page to your server, open in a browser, check your mailbox
    $myEmail = "paul@expocad.com"; //change to your own email
    $myServer = "tech@expocad.com"; //change to your domain
    mail($myEmail, "test message", "test message", "From: ".$myServer); 
    print "MAIL SENT"; 
?>

and


<?
mail("paul@expocad.com","test","Ok, it works");
?> 

neither one of those worked…!

some hosts (its rare though) disable php mail calls on their servers - in fear of spam. Not sure if thats the case here - but might want to see if that is the case first.

This one works fine on my 1&1 host. Try it:

If it doesn’t work then your host probably doesn’t support mail.


<?php
$email = "paul@expocad.com";
$subject = "This is a test email subject";

$headers = "From: paul@expocad.com
";
$headers .= "Content-Type: text/html; charset=ISO-8859-1 ";
$headers .= "MIME-Version: 1.0 ";

$message = "This is a test email";



$mail = mail($email,$subject,$message,$headers);
if($mail) {
    echo "Message Sent.";
} else {
    echo "Error.";
}
?>

Actually, all traffic on port 25 ( mail ) has been disable becouse of spam.
in order to send mails via PHP, you need to send from your ISP (if the server is localy) mailserver)

Im using comhem, and then i just send from mail.comhem.com.

Is your server locally?