is it wise to use php 4.2.3 to send mails.. using php mail() function?
whether 4.2.3 supports php mail() function?
Collapse
X
-
-
is anything wrong in this code?
i get result cant send mail...Code:<?php if(isset($_POST['email'])) { $email_to = ""; //mail id $email_subject = ""; $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $services = $_POST['services']; $message = $_POST['message']; $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Name: ".clean_string($name)."\n"; $email_message .= "Email: ".clean_string($email)."\n"; $email_message .= "Phone: ".clean_string($phone)."\n"; $email_message .= "Services: ".clean_string($services)."\n"; $email_message .= "Message: ".clean_string($message)."\n"; // create email headers $headers = 'From: '.$email."\r\n". 'Reply-To: '.$email."\r\n" . 'X-Mailer: PHP/' . phpversion(); //mail($email_to, $email_subject, $email_message, $headers); if (mail($email_to, $email_subject, $email_message, $headers)) { echo "<h4>Thank you for sending email</h4>"; } else { echo "<h4>Can't send email</h4>"; } ?> <?php } ?>
script runs in php 4.2.3... is anything do with the script?
plz help.Comment
-
Two things:
Put:at the top of your page so we can see any errors.Code:ini_set('display_errors',1); error_reporting(E_ALL);
Then change your mail() to exclude headers by changing line 39 to:
What happens then?Code:if (mail($email_to, $email_subject, $email_message))
Comment
-
Well it looks like your SMTP settings in your php.ini that may not be working. What do you have in your php.ini? Also bear in mind that when you change something in php.ini, you should check that it has taken effect by running a script with:
And if it hasn't taken effect, you may need to restart your server.Code:<?php phpinfo(); ?>
It's probably worth googling:
To see some solutions of what to look for/check when you get that warning.Code:Warning: Failed to connect to mailserver, verify your "SMTP" setting in php.ini
Comment
Comment