SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2003
    Location
    ohio
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking Greetings Friends - Easy one about mail()

    Greetings, I wrote a nice "link to us" page for my buddy that sends an email from the server to both the link requestee and the link requestor. All works great except for one small problem. The emails both say the From Field is "Apache". Any suggestions you have would be much appreciated.

  2. #2
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is an example at php.net:
    Code:
    <?php
    mail("nobody@example.com", "the subject", $message,
         "From: webmaster@{$_SERVER['SERVER_NAME']}\r\n"
        ."Reply-To: webmaster@{$_SERVER['SERVER_NAME']}\r\n"
        ."X-Mailer: PHP/" . phpversion());
    ?>
    Also, I find the mail class of phpmailer very useful.
    http://phpmailer.sourceforge.net/
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  3. #3
    SitePoint Addict
    Join Date
    Oct 2003
    Location
    United States
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $mailheaders "From: link-pimp\n";
    $mailheaders .= "Reply-To: [email=link-pimp@mail.comnn]link-pimp@mail.com\n\n[/email]";
    mail($to$subject$msg$mailheaders); 

    EDIT: You beat me to it.

  4. #4
    SitePoint Enthusiast
    Join Date
    Sep 2003
    Location
    ohio
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That helped a great bit! Thanks guys. I added some more error checking and it seems the email address from the form isn't making it to the PHP script.

    I am using this bit:
    Code:
    $youremail = $HTTP_POST_VARS['youremail'];
    Does an email address require greater parsing?

  5. #5
    SitePoint Wizard Mike Borozdin's Avatar
    Join Date
    Oct 2002
    Location
    Edinburgh, UK
    Posts
    1,743
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tmapm
    PHP Code:
    $mailheaders "From: link-pimp\n";
    $mailheaders .= "Reply-To: link-pimp@mail.com\n\n";
    mail($to$subject$msg$mailheaders); 
    EDIT: You beat me to it.
    This is good too...........

    PHP Code:
    $mailheaders "From: link-pimp <link-pimp@mail.com>\n";
    $mailheaders .= "Reply-To: [email=link-pimp@mail.comnn]link-pimp@mail.com\n\n[/email]";
    mail($to$subject$msg$mailheaders); 

  6. #6
    SitePoint Addict
    Join Date
    Oct 2003
    Location
    United States
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by link-pimp
    That helped a great bit! Thanks guys. I added some more error checking and it seems the email address from the form isn't making it to the PHP script.

    I am using this bit:
    Code:
    $youremail = $HTTP_POST_VARS['youremail'];
    Does an email address require greater parsing?
    Your PHP version is probably higher and requires you to use
    PHP Code:
    $youremail $_POST['youremail']; 
    If that still doesn't work post your form code etc so we can help you designate why the value isn't there.

  7. #7
    SitePoint Enthusiast
    Join Date
    Sep 2003
    Location
    ohio
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    Thanks guys! It was an error on my part. I incorporated your suggestions and all is well. Thanks for the help, as usual.


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
  •