Zend - The PHP Company




Email

Add Code


Form Mail  

Type: application
Added by: RLYNCH
Entered: 27/01/2000
Last modified: 07/12/2009
Rating: **** (21 votes)
Views: 46679
Sends a FORM results via email


<HTML><BODY BGCOLOR=FFFFFF>
    <?php
      $to 
'youremail@yourhost.www';
      
$from 'autoreply@yourhost.www';
      
        
//Check if we have something POSTed by the form.
        
if (isset($HTTP_POST_VARS)){
            
//Start with an empty body for the mail message
            
$body '';
            
//Iterate through all the POSTed variables, and add them to the message body.
            
while (list($key$value) = each($HTTP_POST_VARS)){
                
$body .= $key ' = ' $value "rn";
            }
            
//Build up some nice From/Reply Headers
            
$headers "From: $fromrn";
            
$headers .= "Reply-To: $fromrn";
            
//Mail the message out.
            //Requires setting php3.ini sendmail path as per instructions
            
$success mail($to"Posted " date("m/d/Y"), $body$headers);
            
//Always check return codes from functions.
            
if ($success){
                echo 
"<B><CENTER>Thank you for your input</CENTER></B>n";
            }
            else{
                echo 
"<CENTER><B>Internal Error</B>:  Your input was unprocessed.<BR>Contact $from</CENTER>n";
            }
        }
    
?>
    <FORM ACTION=formmail.php METHOD=POST>
        <INPUT NAME=sample><BR>
        <INPUT TYPE=SUBMIT>
    </FORM>
</BODY></HTML>


Usage Example




Rate This Script





Search



This Category All Categories