how to get form data to email???

Discussion in 'PHP' started by mylooieva, Jul 28, 2009.

  1. #1
    I am beginner of php. And i know very little about it. I already create a form in dreamweaver. When i fill in the form, by click the submit button, the form data will email to the particular people. Can it be done??? Anybody can help? Can explain more or state clearly the step so that i can understand. Thanks. :)
     
    mylooieva, Jul 28, 2009 IP
  2. ptalent

    ptalent Peon

    Messages:
    26
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    if you're email form is like this:

    
    <form action="send.php" method="post">
    
    Your email: <input type="text" name="email" /> <br/>
    Your message: <textarea name="message"></texarea> <br/>
    <input type="submit" name="submit" />
    
    </form>
    
    Code (markup):
    send.php should look like this:

    
    if (isset($_POST['submit'])) {
    
    	$message= $_POST['message'];
    	$email = $_POST['email'];
    
      	$recipients = 'your@email.com';
    	$subject = "Website Enquiry";
    
    	$body = '';
    	$body .= '<strong>E-Mail:</strong> ' . $email . '<br />';
    	$body .= $message;
    
    	if ( mail($recipients,$subject,$body) ) {
    		echo 'Your message has been sent successfully.';
    	} else {
    		echo '<h1 class="error">Your email has not been sent. Please try again.</h1>';	
    	}
    }
    
    PHP:
     
    ptalent, Jul 28, 2009 IP
  3. wrxbuzz

    wrxbuzz Peon

    Messages:
    41
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    wrxbuzz, Jul 28, 2009 IP
  4. mylooieva

    mylooieva Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    i use the method :

    $headers = 'MIME-Version:1.0'."\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n";
    $headers .= 'From: '."\r\n";
    mail($to, $subject, $message, $headers);

    but if got Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 <mylooieva@gmail.com>... Relaying denied. IP name possibly forged [115.135.59.70] in C:\xampp\htdocs\ischeduling\ict_code.php on line 30

    Anybody know how to solve this problem?
     
    mylooieva, Jul 28, 2009 IP
  5. Martinoes

    Martinoes Peon

    Messages:
    110
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    550 - The requested command failed because the user's mailbox was unavailable (for example because it was not found, or because the command was rejected for policy reasons).
     
    Martinoes, Jul 29, 2009 IP