Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Oct 2007
    Location
    Glencoe, Ontario, Canada
    Posts
    340
    Thanks
    19
    Thanked 27 Times in 27 Posts

    Email form From:

    Is there a way to have it so the form puts then senders email in the Heading instead of mine.

    Cause I use mozilla thunderbird and when you check the email it puts it as such

    Subject: then the subject

    To: my email

    Date: Date sent.

    From: senders email


    But my form it puts my email in the from section I have tried many ways to get around it, it either no longer sends the form email or it sends it by saying eric@node64.com or something


    Any help would be appreciated;

    PHP Code:
    $EmailFrom "eric@habugfx.com";

    // I have tried putting $email; "From: $email"; but nothing works.
                
    $EmailTo "eric@habugfx.com";
                
    $Subject "Habu GFX Contact Form";
                
                
    // prepare email body text
                
    $Body "";
                
    $Body .= "Name: ";
                
    $Body .= $name;
                
    $Body .= "\n";
                
    $Body .= "Email: ";
                
    $Body .= $email;
                
    $Body .= "\n";
                
    $Body .= "Message: ";
                
    $Body .= $message;
                
    $Body .= "\n";

                
    // send email 
                
    $success mail($EmailTo$Subject$Body"From: <$EmailFrom>"); 
    image of what i mean

    http://www.eric.dragonethosting.com/screenie.jpg
    Last edited by PitbullMean; 03-11-2009 at 01:29 AM.
    Eric "PitbullMean" Melo
    Always Start your layout with*{border:0; margin:0; padding:0;}
    Be sure to Thank ALL Users who give assistance.

  • #2
    Regular Coder ninnypants's Avatar
    Join Date
    Apr 2008
    Location
    Utah
    Posts
    504
    Thanks
    10
    Thanked 47 Times in 47 Posts
    You just need to require the senders email and pull it out of the post/get data.
    PHP Code:
    $EmailFrom $_POST['from'];

    // I have tried putting $email; "From: $email"; but nothing works.
                
    $EmailTo "eric@habugfx.com";
                
    $Subject "Habu GFX Contact Form";
                
                
    // prepare email body text
                
    $Body "";
                
    $Body .= "Name: ";
                
    $Body .= $name;
                
    $Body .= "\n";
                
    $Body .= "Email: ";
                
    $Body .= $email;
                
    $Body .= "\n";
                
    $Body .= "Message: ";
                
    $Body .= $message;
                
    $Body .= "\n";

                
    // send email 
                
    $success mail($EmailTo$Subject$Body"From: <$EmailFrom>"); 

  • #3
    Regular Coder
    Join Date
    Oct 2007
    Location
    Glencoe, Ontario, Canada
    Posts
    340
    Thanks
    19
    Thanked 27 Times in 27 Posts
    Nope didnt send the email at all, heres the full php code.


    PHP Code:
    <?php
    //DO NOT REMOVE THIS PHP CODE
    if (isset($_POST['submit'])) {
        
    $name $_POST['Name'];
        
    $email $_POST['Email'];
        
    $message $_POST['Message'];
        
        if (empty(
    $name))
            
    $err1 1;
        elseif (empty(
    $email))
            
    $err2 1;
        elseif (empty(
    $message))
            
    $err3 1;
        else {
            if (!
    preg_match('/^([a-z0-9])([\w\.\-\+])+([a-z0-9])\@(([\w\-]?)+\.)+([a-z]{2,4})$/i',$email))
                
    $err4 1;
            else {
                
    $EmailFrom "eric@dragonethosting.com";
                
    $EmailTo "eric@habugfx.com";
                
    $Subject "Habu GFX Contact Form";
                
                
    // prepare email body text
                
    $Body "";
                
    $Body .= "Name: ";
                
    $Body .= $name;
                
    $Body .= "\n";
                
    $Body .= "Email: ";
                
    $Body .= $email;
                
    $Body .= "\n";
                
    $Body .= "Message: ";
                
    $Body .= $message;
                
    $Body .= "\n";

                
    // send email 
                
    $success mail($EmailTo$Subject$Body"From: <$EmailFrom>");
            }
            
        }
    }
    ?>
    Eric "PitbullMean" Melo
    Always Start your layout with*{border:0; margin:0; padding:0;}
    Be sure to Thank ALL Users who give assistance.

  • #4
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    Take a look at example #2: http://us2.php.net/manual/en/function.mail.php

    Keep in mind that changing the From header to an email address that is not a valid address at your domain may not be advisable. Your mail server could block it; the recipients mail server could consider it spam. The Reply-To header may be a (less than perfect) alternative.
    John

  • #5
    New Coder
    Join Date
    Aug 2008
    Posts
    22
    Thanks
    0
    Thanked 2 Times in 2 Posts
    it should be this
    Code:
    $EmailFrom = $email
    I would say you need to print out $err1, $err2, $err3, $err4, just to be sure its getting to the mail part

  • #6
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Is there a way to have it so the form puts then senders email in the Heading instead of mine.

    Cause I use mozilla thunderbird and when you check the email it puts it as such

    Subject: then the subject

    To: my email

    Date: Date sent.

    From: senders email
    You could use popular php-mailer classes like PHPMailer Or SwiftMailer to reduce the hassles.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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