# Php send mail not working.



## peterjcs (Jan 23, 2007)

I want to create a contact form and user send the information to my yahoo e-mail. But i did not receive any mail at yahoo. The web host can support the send mail function.

help please. Thank


```
<?php
function spamcheck($field)
  {
//eregi() performs a case insensitive regular expression match
  if(eregi("to:",$field) || eregi("cc:",$field)) 
    {
    return TRUE;
    }
  else
    {
    return FALSE;
    }
  }//if "email" is filled out, send email
if (isset($_REQUEST['email']))
  {
  //check if the email address is invalid
  $mailcheck = spamcheck($_REQUEST['email']);
  if ($mailcheck==TRUE)
    {
    echo "Invalid input";
    }
  else
    { 
    //send email
    $email = $_REQUEST['email'] ; 
    $subject = $_REQUEST['subject'] ;
    $message = $_REQUEST['message'] ;
    mail("[email protected]", "Subject: $subject", $message, "From: $email" );
    echo "Thank you for using our mail form";
    }
  }
else
//if "email" is not filled out, display the form
  {
?>
  
<form action="contact.php" method="post">

<table width="100%" border="0">
  <tr>
    <td width="16%"><strong>Your E-Mail: </strong></td>
    <td width="84%"><input name='email' type='text' size="50" maxlength="50" /></td>
  </tr>
  <tr>
    <td><strong>Subject:</strong></td>
    <td><input name='subject' type='text' size="50" maxlength="50" /></td>
  </tr>
  <tr>
    <td><strong>Message:</strong></td>
    <td> </td>
  </tr>
  <tr>
    <td colspan="2"><textarea name='message' rows='15' cols='40'></textarea></td>
    </tr>
  <tr>
    <td colspan="2"><input type="submit" name="Submit" value="Send" /></td>
  </tr>
</table>


</form>

  
<?php
  }
?>
```


----------



## Sc0tt (Aug 15, 2007)

Hey Peterjcs,

Did you change this part mail("[email protected]" to your actual email address?

I'm assuming you changed it so your email isn't posted here, if not then that would be a good place to start.


----------



## peterjcs (Jan 23, 2007)

Yes, i am using my real email address at the code. I just change it to [email protected] when i post it to here. 

Do you know why cannot send to yahoo mail?


----------



## Sc0tt (Aug 15, 2007)

Then I have no idea.  Sorry can't think today. Did you check your spam box? 

I can reccomend a script, I use it alot and don't have any problems.

http://www.scriptarchive.com/formmail.html


----------



## peterjcs (Jan 23, 2007)

I ok Sc0tt. i will try the script you recommend. thank


----------

