Menu

From Field In Email

Help
2009-07-24
2013-06-03
  • Howard Canning

    Howard Canning - 2009-07-24

    Hi,
    How do you define the from field in the email. The From field shows eg hcanning2008@p3nxyz13.shr.prod.phx3.secureserver.net  from hcanning2008.
    Can I set it up so it reads feedback@mywebsite.com from Website Feedback?
    Thanks

     
    • TNTEverett

      TNTEverett - 2009-07-25
       
    • Dwayne Casey

      Dwayne Casey - 2009-08-27

      Excellent ..thank you.... I needed this as well.   Should have been a no brainer.   

       
  • Anonymous

    Anonymous - 2009-11-20

    This website helped me.

    http://www.cyberciti.biz/faq/howto-change-from-email-address-php-mail-function/

    I had to do some tweaking to the processor.php file but it works great! I believe I removed the top line with the 'server name' in it and moved the mail part to the bottom. I put in $message=" at the top and in the mail section. And then in the mail section in the bottom add $message too.

    I hope that makes sense. :)

     
  • Anonymous

    Anonymous - 2009-11-20

    I didn't even see the reply above mine. That works too!

     
  • Jorge

    Jorge - 2009-12-14

    Hi guys,

    I'm having issues with this to. I tried following the instructions on this post and spent almost 1 hour searching the internet for solutions on this same issue and everyone is saying the same thing that is being suggested on here.

    If someone can please simplify it for me and break it down step by step on what's the simplest way to have the "**from email address**" be the email address the user entered in the form. Thank you.

     
  • TNTEverett

    TNTEverett - 2009-12-15

    It's hard to get much clearer than this "Example #2".

    http://php.net/manual/en/function.mail.php

     
  • Jorge

    Jorge - 2009-12-15

        <?php $where_form_is="http://".$_SERVER.strrev(strstr(strrev($_SERVER),"/"));session_start();
    if( ($_SESSION==$_POST) && (!empty($_POST)) ) {mail("webmaster@mydomain.com","Contact - Form Submission","Form data:

    Name:: " . $_POST . "
    Email:: " . $_POST . "
    Message:: " . $_POST);include("confirm.html");
    }
    else {
    echo "Invalid Verification Security Code. Please go back and try again.";}?>

     
  • Jorge

    Jorge - 2009-12-15

    <?php $where_form_is="http://".$_SERVER.strrev(strstr(strrev($_SERVER),"/"));session_start();
    if( ($_SESSION==$_POST) && (!empty($_POST)) ) {mail("webmaster@mydomain.com","Contact - Form Submission","Form data:

    Name:: " . $_POST . "
    Email:: " . $_POST . "
    Message:: " . $_POST);include("confirm.html");
    }
    else {
    echo "Invalid Verification Security Code. Please go back and try again.";}?>

     
  • Jorge

    Jorge - 2009-12-15

    Sorry for the double post, but that's the code I'm working with in my **processor.php**. I'm not sure how to incorporate the examples into my code. I tried to include *example 2* into my code, but it did not work.

     
  • TNTEverett

    TNTEverett - 2009-12-15

    <?php
    sessionstart();
    $whereformis="http://".$SERVER.strrev(strstr(strrev($SERVER),"/"));
    if( ($SESSION==$POST) && (!empty($POST)) ) {
    $to = 'webmaster@mydomain.com';
    $subject = 'Contact - Form Submission';
    $message = "Form data: Name: " . $POST . " Email: " . $POST . " Message: " . $POST;

    $headers = 'From: ".$POST."' . "\r\n" .
        'Reply-To: webmaster@mydomain.com' . "\r\n" .
        'X-Mailer: PHP/' . phpversion();

    mail($to, $subject, $message, $headers);

    include("confirm.html");
    } else {
    echo "Invalid Verification Security Code. Please go back and try again.";
    }
    ?>

     
  • Jorge

    Jorge - 2009-12-17

    Hi tnteveret1,

    I used your code, but it still did not work, it just took me to a blank page. What if I try doing what **laisunshine** said and remove the top line with the 'server name' in it, you think that will then make your code work?

     
  • Aaron Hardy

    Aaron Hardy - 2009-12-18

    tnteveret1 did you ever write a tutorial for this? Cuz, people ask this a lot. I will look into it but I never really tried to find out.

     
  • laisunshine

    laisunshine - 2010-01-18

    What if I don't want my email to appear? Can I set it up so that the customer's email appears instead? Thanks!

     
  • TNTEverett

    TNTEverett - 2010-01-21

    Follow example 2 at this link.

    http://www.w3schools.com/PHP/func_mail_mail.asp

     
  • laisunshine

    laisunshine - 2010-01-21

    So if I use example 2, whoever is filling out the form, their email will appear in the from field? I tried this and only the email that is in the "from"  appears. In this case the webmaster@example.com appears.

    $headers = "From: webmaster@example.com" . "\r\n" .

     
  • TNTEverett

    TNTEverett - 2010-01-21

    You obviously have to know which form field you want to use, then insert the form field value into the "From" field in the example.
    $headers = "From: ".$whatever_form_field_value." . "\r\n" .

     
  • Howard Canning

    Howard Canning - 2010-02-19

    RESOLVED
    Do following in processor.php
    replace:
    ");

    include("yourconfirmationpage.html");

    with

    ","from: website_query@yourwebsite.com" );

    include("yourconfirmationpage.html");

    ////paste it in from notepad. Its a bit tempermental pasting. Works perfect. Stops me getting the server generated from email "H-Sphere Httpd Daemon "

    Hope this helps!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.