email form , the sender shows up as "me@locahost" in my email, can i change that?

Discussion in 'PHP' started by visualkreations, Aug 4, 2009.

  1. #1
    i have a pretty basic php email form, but for some reason when it sends the email , the "from" address shows up as "me@locahost.com" is there a way i can change that to something else?

    Thanks.
     
    visualkreations, Aug 4, 2009 IP
  2. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If you're just using the php mail() function, this is how you're supposed to do it:

    <?php
    $to      = 'nobody@example.com';
    $subject = 'the subject';
    $message = 'hello';
    $headers = 'From: webmaster@example.com' . "\r\n" .
        'Reply-To: webmaster@example.com' . "\r\n" .
        'X-Mailer: PHP/' . phpversion();
    
    mail($to, $subject, $message, $headers);
    ?>
    
    PHP:
    If you're not, post the code sample here.
     
    premiumscripts, Aug 4, 2009 IP
  3. Sky AK47

    Sky AK47 Member

    Messages:
    298
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    45
    #3
    AKA, you have to add the optional header parameter for the mail function.
    As given above, 'From: ', can be used to define the sender.
     
    Sky AK47, Aug 4, 2009 IP
  4. visualkreations

    visualkreations Well-Known Member

    Messages:
    454
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    108
    #4
    I see , thanks a lot I will try this
     
    visualkreations, Aug 4, 2009 IP
  5. EverestTech

    EverestTech Well-Known Member

    Messages:
    554
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    140
    #5
    EverestTech, Aug 4, 2009 IP