Mail function (php) works!

Status
Not open for further replies.

springbox99

Member
Messages
114
Reaction score
3
Points
18
I don't know when, I don't know why, I don't where on this site i've found the code, but I had created a file named testmail.php. And I fell on it during an operation of maintenance of my site. As the mail function stopped working since the last update of the servers, I opened it to see. And ... It works!
So I used it to rewrite the code of my contact pages. Everything is OK now.
Here is the content of testmail.php:
<?php
// TEST OF THE MAIL SYSTEM USING PHP mail()
// this must be a valid email account on your domain

$from = "xxx@xxx.com";

// DOES NOT BOUNCE BACK FROM hotmail!!

$to="xxxx@xxx.com";


$mailbody="Test message sent (PST): \n" . date('l jS \of F Y h:i:s A');
$subject="Test of PHP mail()" ;

// NOT text/html
$headers = "Content-type: text/plain; charset=windows-1251 \r\n";

$headers .= "From: $from\r\n";
$headers .= "Reply-To: $from\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "X-Mailer: PHP/" . phpversion();

$resp = mail($to, $subject, $mailbody, $headers);

if( $resp ){
$outcome = "Mail sent" ;
} else {
$outcome = "Mail not sent";
}

print "\nThe mail system said: $outcome\n\n" ;
exit();
?>

I hope it will be usefull.
 
Status
Not open for further replies.
Top