mail() function in php stopped working

Status
Not open for further replies.

damirzay76

New Member
Messages
2
Reaction score
0
Points
0
Hi,
I have got php file in my site that takes data entered by user and sends it using mail() function. It has been tested and was working for more than 10 days and one or two days ago I have noticed that is not working anymore.
It is not sending emails and it returns "false" value as a bool in php

I didn't do any changes in the code.
Could you please confirm that your smtp server is configured correctly and that your version of php supports mail() php function.
If everything is configured correctly tell me what might be the reasons why mail() function stopped working on my page.
Thank you,
Damir
 

Corey

I Break Things
Staff member
Messages
34,551
Reaction score
204
Points
63
Do you have a link to the script\page?
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
The following script runs fine on Chopin.
Gmail accepts it.
Hotmail does not bounce it, but does put it in the Spam folder.

PHP:
<?php

date_default_timezone_set('America/Los_Angeles');
echo date('l jS \of F Y h:i:s A'); 
echo "\n";

$from = "myName@myDomain.x10.bz";
$to="myGmailAccount@gmail.com";

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

$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();

?>

You can see if it runs on your server.
Please note that the "From" is a real email account on your hosting account.
 
Last edited:

damirzay76

New Member
Messages
2
Reaction score
0
Points
0
Thank you for your replies:
Here is the code that was working ( and stopped working now) on Hosting Server: boru

It was working with googlemail and yahoo and now I am getting part of code executed that loads contact.php?status=failure, i.e. $sent = false and ,of course, the mail is not being sent. Anyway I was planning to move to paid hosting, so will try maybe this will solve the problem

PHP:
<?php

$to = "MYTESTEMAIL@googlemail.com" ; 
$name = $_REQUEST['name'] ;
$subject = $_REQUEST['subject'] ;
$email = $_REQUEST['email'] ; 
$message = $_REQUEST['message'] ; 
$intro = "We have received the following information:\n\n";
$txt = sprintf("%s The message from: %s \n Email: %s \n Message: \n\n %s",$intro,$name,$email,$message);
$headers = "Email from : ". $name; 
$sent = mail($to, $subject, $txt, $headers) ; 
if($sent) 
	{
	echo "<script type=\"text/javascript\"> location.replace(\"contact.php?status=success\"); //</script>";
	}
else 
	{
	echo 
	"<script type=\"text/javascript\"> location.replace(\"contact.php?status=failure\"); </script>";
	}  

?>
 
Last edited:
Status
Not open for further replies.
Top