SitePoint Sponsor

User Tag List

Results 1 to 14 of 14

Thread: From: nobody

  1. #1
    SitePoint Zealot grantus's Avatar
    Join Date
    Apr 2003
    Location
    TX
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    From: nobody

    I've seen a way around this before, but I can't remember where. I have a small form that have the results emailed to me and to the person filling out the form. The problem is that the email sent to the recipient shows "From: nobody@nocdirect.com"

    How do I fix it so that it shows "From: my site" or "From: me@mysite.com"???

    Thanks!

  2. #2
    SitePoint Zealot sidhighwind's Avatar
    Join Date
    Aug 2003
    Location
    Indianapolis, IN
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do something like this
    PHP Code:
    $to "me at me.com";
    $message "hello";
    $subject "Good Day Sir";
    $header "From: [email]me@me.com[/email]";

    @
    mail($to,$subject,$message,$header); 
    What that does is it rewrites the header of the mail message to be from who ever you specify.

    hope this helped..
    Jon Whitcraft :: It's the Bombdiggity!
    Web Applications Developer :: Zend Certified Engineer
    http://www.indycar.com

  3. #3
    SitePoint Zealot grantus's Avatar
    Join Date
    Apr 2003
    Location
    TX
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried that and I got an error.

    I just put this in my script and it seems to work fine:
    PHP Code:
    "From: MySite<me@mysite.com>\nX-Mailer: PHP/" phpversion() 
    Would there be a potential problem with this code?

  4. #4
    SitePoint Zealot sidhighwind's Avatar
    Join Date
    Aug 2003
    Location
    Indianapolis, IN
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No I dont see a problem with it.
    Jon Whitcraft :: It's the Bombdiggity!
    Web Applications Developer :: Zend Certified Engineer
    http://www.indycar.com

  5. #5
    SitePoint Zealot grantus's Avatar
    Join Date
    Apr 2003
    Location
    TX
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ahh, cool. It's basically my first script that I put together so I'm still not sure of a few things.

    Thanks!

  6. #6
    SitePoint Zealot grantus's Avatar
    Join Date
    Apr 2003
    Location
    TX
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, can you help me with something else?

    When I get the results of the form emailed to me, if the person put this for example: I'll - it shows up as I\'ll. What can I do in my script to fix that?

  7. #7
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    stripslashes() the $message.
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  8. #8
    SitePoint Zealot grantus's Avatar
    Join Date
    Apr 2003
    Location
    TX
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What do I do exactly? Sorry, I'm still learning all this!

    Thanks.

  9. #9
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can you post the mail() code you have?
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  10. #10
    SitePoint Zealot grantus's Avatar
    Join Date
    Apr 2003
    Location
    TX
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm sure it would make it easier eh?

    PHP Code:
    <?php 
    // ************Begin Configure*************** 
    //Put where you want the email to go 
    $mailto "me@mysite.com"
    //Put your subject in here 
    $subject "Info"
    //Put where to redirect to after sending the email 
    $redirect "contact_thanks.php"
    //Name of person filling out the form
    $name $_REQUEST['name'];
    //Email address from person filling out the form
    $email $_REQUEST['email'] ;
    //Comments field
    $comments $_REQUEST['comments'];
    // ************End Configure**************** 

    foreach($HTTP_POST_VARS as $key => $value) { 

    $message .= $key ': ' $value
    $message .= "\n"//Note the double quotes

    }

    mail("$email""Info""$name,\n
    Thank you for your inquiry!\n
    This is an auto-response to confirm the email you sent to our staff.  You will be contacted shortly regarding your message.\n
    Here's the information that you sent:
    Name:  
    $name\r
    Email:  
    $email\r
    Comments:  
    $comments\n
    Thanks"
    "From: Admin<me@mysite.com>\nX-Mailer: PHP/" phpversion());

    header("From: $email"); 
    if (@
    mail($mailto$subject$message"From: $email)) { 

    header("Location: $redirect"); 
    } else { 
    // This echo's the error message if the email did not send. 
    // You could change the text in between the <p> tags. 
    echo('<p>Mail could not be sent. Please use your back button to try again.</p>'); 

    ?>

  11. #11
    orange pips! orange pips!
    Join Date
    Oct 2001
    Location
    Its all about location
    Posts
    652
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by grantus
    I'm sure it would make it easier eh?
    PHP Code:
    <?php 
    // ************Begin Configure*************** 
    //Put where you want the email to go 
    $mailto "me@mysite.com"
    //Put your subject in here 
    $subject "Info"
    //Put where to redirect to after sending the email 
    $redirect "contact_thanks.php"
    //Name of person filling out the form
    $name $_REQUEST['name'];
    //Email address from person filling out the form
    $email $_REQUEST['email'] ;
    //Comments field
    $comments $_REQUEST['comments'];
    // ************End Configure**************** 

    foreach($HTTP_POST_VARS as $key => $value) { 

    $message .= $key ': ' $value
    $message .= "\n"//Note the double quotes

    }

    mail("$email""Info""$name,\n
    Thank you for your inquiry!\n
    This is an auto-response to confirm the email you sent to our staff. You will be contacted shortly regarding your message.\n
    Here's the information that you sent:
    Name: 
    $name\r
    Email: 
    $email\r
    Comments: 
    $comments\n
    Thanks"
    "From: Admin<me@mysite.com>\nX-Mailer: PHP/" phpversion());

    header("From: $email); 
    if (@
    mail($mailto$subject$message"From: $email)) { 

    header("Location: $redirect); 
    } else { 
    // This echo's the error message if the email did not send. 
    // You could change the text in between the <p> tags. 
    echo('<p>Mail could not be sent. Please use your back button to try again.</p>'); 

    ?>
    Change your "Comments: $comments" line to "Comments: stripslashes($comments)".

  12. #12
    SitePoint Zealot grantus's Avatar
    Join Date
    Apr 2003
    Location
    TX
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by krayziepjf
    Change your "Comments: $comments" line to "Comments: stripslashes($comments)".
    To this?

    PHP Code:
    Commentsstripslashes($comments
    It doesn't work.

  13. #13
    orange pips! orange pips!
    Join Date
    Oct 2001
    Location
    Its all about location
    Posts
    652
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by grantus
    To this?
    PHP Code:
    Commentsstripslashes($comments
    It doesn't work.
    Sorry, like this:

    PHP Code:
    Comments" . stripslashes($comments) . " 

  14. #14
    SitePoint Zealot grantus's Avatar
    Join Date
    Apr 2003
    Location
    TX
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It works! But that's for the email being sent to the recipient. The email that gets sent to me still has it, so where would I put the stripslashes for that? I know it's $message, but I'm not sure which one. Would it be in here:

    PHP Code:
    foreach($HTTP_POST_VARS as $key => $value) { 

    $message .= $key ': ' $value
    $message .= "\n"//Note the double quotes


    Or here:

    PHP Code:
    header("From: $email); 
    if (@
    mail($mailto$subject$message"From: $email)) 


Bookmarks

Posting Permissions

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