Jump to content

Recommended Posts

Hi

 

I have setup a php “email to” form script from my website this form works fine when sending to a web mail I can receive them ! The problem I am having is receiving the emails messages through outlook! The outlook email can receive emails fine when normally sent direct from another email so I know that it’s working correctly, but can not receive emails that are sent through the php “email to” form script.

Has anyone come across this problem before? Can you help? (There are no error messages!  Just no emails that are sent from the “email to” form script) The code that im using is as follows

 

 

define("MAIL_TARGET","chris@mortgagepark.co.uk , track@mortgagepark.co.uk");

 

ini_set("sendmail_from", "root@mortgagepark.co.uk");

 

 

 

chris@mortgagepark.co.uk – this is the  email has been configured to outlook and can not receive emails from the form !

 

 

track@mortgagepark.co.uk - this is NOT configured to outlook so its just  webmail and can receive emails from the php “email to” form script

 

 

 

If anyone knows if this is a scripting problem or a outlook problem please reply as im getting to the stage of smashing my PC up !!!!!!

 

 

Cheers Jay ( Mediator )

 

Link to comment
https://forums.phpfreaks.com/topic/53556-php-mail-help/
Share on other sites

 

<?php

 

// Define your email address - where to send messages - here

define("MAIL_TARGET","chris@mortgagepark.co.uk , track@mortgagepark.co.uk");

ini_set("sendmail_from", "root@mediadiverse.org.uk");

 

// Here you can redefine error messages

define("errorName","Invalid name! It must be at least 2 characters long");

define("errorEmail","Invalid email address!");

define("errorMsg","Invalid message! It must be at least 10 characters long");

 

function createForm($name="",$email="",$tel="",$questions="",$contact="",$error1="",$error2="",$error3=""){

?>

   

  <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

        <table>

 

          <tr>

<td 200px>Your Name<?php echo $error1; ?></td>

  <td><input class="text" type="text" name="name" value="<?php echo $name; ?>"></td>

  </tr>

 

          <tr>

<td 200px>Your Email:<?php echo $error2; ?></td>

  <td><input class="text" type="text" name="email" value="<?php echo $email; ?>"></td>

  </tr>

 

       

 

 

 

 

 

    <tr>

<td 200px>Your Phone Number:<?php echo $error3; ?></td>

<td><input class="text" type="text" name="tel"value="<?php echo $tel;?>"></td>

  </tr>

 

 

 

 

 

 

  <tr>

  <td 200px>Your Question<?php echo $error3; ?></td>

<td><textarea cols="30" rows="4" name="questions"><?php echo $questions;?></textarea></td>

  </tr>

 

 

 

 

 

 

 

  <td 200px>When can we Contact you :<?php echo $error3; ?></td>

 

  <td colspan="2"><select name="contact">

  <option>Morning</option>

  <option>Evening</option>

  <?php echo $contact; ?>

  </select>   </td>

</tr>

 

 

 

          <tr>

<td 200px><br/><input class="text" type="submit" name="submitBtn" value="Send"></td>

  <td><br/></td>

  </tr>

        </table>

      </form>

 

 

 

<?php

 

 

 

 

 

}

 

function isValidEmail($email){

  $pattern = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$";

   

  if (eregi($pattern, $email)){

      return true;

  }

  else {

      return false;

  } 

}

 

 

 

function sendMail($name,$email,$tel,$questions,$contact){

 

 

   

    $subject = "**MORTGAGEPARK.CO.UK EMAIL**";

    $from    = "From: $name <$email>\r\nReply-To: $email\r\n";

    $header  = "MIME-Version: 1.0\r\n"."Content-type: text/html; charset=iso-8859-1\r\n";

    $content = ($email.

            "<br /><br />NAME : ".$name.

 

  "<br /><br />TELEPHONE : ".$tel.

 

  "<br /><br /> ANY OTHER QUESTIONS : ".$questions.

 

  "<br /><br />CONTACT THEM : ".$contact

  );

 

 

    $content = wordwrap($content,70);

 

   

    mail(MAIL_TARGET,$subject,$content,$from.$header);

 

 

}

?>

 

THIS NEXT CODE IS IN THE BODY OF THE HTML

 

 

 

 

  <?php if (!isset($_POST['submitBtn']))  {

createForm();

} else  {

  $name    = isset($_POST['name']) ? $_POST['name'] : "";

  $email  = isset($_POST['email']) ? $_POST['email'] : "";

$tel = isset($_POST['tel']) ? $_POST['tel'] : "";

$questions = isset($_POST['questions']) ? $_POST['questions'] : "";

$contact = isset($_POST['contact']) ? $_POST['contact'] : "";

 

  $error = false;

 

  if (strlen($name)<2) {

  $error = true;

  $error1 = errorName;

  }

  if (!isValidEmail($email)) {

  $error = true;

  $error2 = errorEmail;

  }

 

 

 

 

  if ($error){

createForm($name,$email,$tel,$questions,$contact,$error1,$error2,$error3);

  }

  else {

  sendMail($name,$email,$tel,$questions,$contact);

?>

<div id="result">

<table >

  <tr><td>

Your message has been sent to chris@mortgagepark.co.uk !

  </td></tr>

  </table>

  </div>

<?php           

}

}

?>

Link to comment
https://forums.phpfreaks.com/topic/53556-php-mail-help/#findComment-267040
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.