whether 4.2.3 supports php mail() function?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • impin
    New Member
    • Jul 2010
    • 127

    whether 4.2.3 supports php mail() function?

    is it wise to use php 4.2.3 to send mails.. using php mail() function?
  • TheServant
    Recognized Expert Top Contributor
    • Feb 2008
    • 1168

    #2
    mail() is supported in PHP 4.

    Additional parameters is the only parameter you may have issues with in PHP 4.2.3. It was only PHP 4.3 where that was fixed and finalized.

    It is only wise if you use it correctly. Verify and sanitize all input so people don't abuse the system.

    Comment

    • impin
      New Member
      • Jul 2010
      • 127

      #3
      is anything wrong in this code?

      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
      }
      ?>
      i get result cant send mail...

      script runs in php 4.2.3... is anything do with the script?
      plz help.

      Comment

      • TheServant
        Recognized Expert Top Contributor
        • Feb 2008
        • 1168

        #4
        Two things:
        Put:
        Code:
        ini_set('display_errors',1);
        error_reporting(E_ALL);
        at the top of your page so we can see any errors.

        Then change your mail() to exclude headers by changing line 39 to:
        Code:
        if (mail($email_to, $email_subject, $email_message))
        What happens then?

        Comment

        • impin
          New Member
          • Jul 2010
          • 127

          #5
          i get this...

          Warning: Failed to connect to mailserver, verify your "SMTP" setting in php.ini in E:\Program Files\Ensim\WEB ppliance\SiteDa ta\Domains\outs ourceprojectsto india.com\ROOT\ Inetpub\wwwroot \mail.php on line 11
          Mail Not Sent.

          Comment

          • TheServant
            Recognized Expert Top Contributor
            • Feb 2008
            • 1168

            #6
            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:
            Code:
            <?php phpinfo(); ?>
            And if it hasn't taken effect, you may need to restart your server.

            It's probably worth googling:
            Code:
            Warning: Failed to connect to mailserver, verify your "SMTP" setting in php.ini
            To see some solutions of what to look for/check when you get that warning.

            Comment

            Working...