www.webdeveloper.com
Results 1 to 3 of 3

Thread: Contact form - Want users email address to show "sent from"

  1. #1
    Join Date
    Mar 2012
    Posts
    2

    Contact form - Want users email address to show "sent from"

    Hi

    I have a contact from which works fine and sends an email to my email address but its always showing send from "support@hostinguk.net" which is my hosting provider. How do I get the email to show its been sent from the email address thats entered on contact from?

    code is
    Code:
    <?php
    /*** ---------- CHANGE THIS TO YOUR EMAIL ADDRESS ------------- ***/
    $MAIL_TO = 'myemail@domain.co.uk';
    
    /*** ---------------------------------------------------------- ***/
    
    $subject = "Web Site Take The Test :: GG";
    $time = date('d-m-Y H:i');
    
    $fname = $_POST['fname-field'];
    $telephone1 = $_POST['telephone1-field'];
    $telephone2 = $_POST['telephone2-field']; 
    $mail = $_POST['mail-field'];
    $address = $_POST['address-field'];
    $postcode = $_POST['postcode-field'];
    $debts = $_POST['debt-field'];
    $creditors = $_POST['creditors-field'];
    $message = $_POST['message-field'];
    
    $name = $fname . ' ' . $lname;
    
    $body = "Take The Test Sent: $time\n\n";
    $body .= "Name: $name\nTelephone1: $telephone1\nTelephone2: $telephone2\nEmail: $mail\n\nAddress:\n$address\nPost Code: $postcode\n\nHow Debts ?: $debts\nHow many creditors: $creditors\n\n";
    $body .= "Message:\n$message";
    
    @mail($MAIL_TO, $subject, $body);
    echo 'sent!';
    ?>
    any help would be great, thanks

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,616
    PHP Code:
    $headers "Reply-To: " filter_var($mailFILTER_SANITIZE_EMAIL);
    mail($MAIL_TO$subject$body$headers); 
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Feb 2012
    Posts
    218
    From http://php.net/mail
    PHP Code:
    $headers 'From: webmaster@example.com' "\r\n" .
        
    'X-Mailer: PHP/' phpversion();

    mail($MAIL_TO$subject$body$headers); 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles