Help with email functionality

Discussion in 'PHP' started by fishercraigj, Jul 17, 2009.

  1. #1
    Hey all,

    FYI - I'm not a PHP guy but I am usually able to figure things out. I downloaded a template for a website. Everything is great except for the email for submit. I keep getting an error while trying to send. If you want to see the error in action, go to www.craigfisherlive.com and click on the "contact me" page and try to use the form. You'll see exactly what's going on.

    The PHP code for the contact pape looks like this:

    <?PHP
    $to = "fishercraigj@gmail.com";
    $subject = "www.craigfisherlive.com";
    $e = $_POST['email_txt'];
    $message = "Name: " . $_POST['name_txt'];
    $message .= "\nE-mail: " . $e;
    $message .= "\nPhone: " . $_POST['phone_txt'];
    $message .= "\n\nMessage: " . $_POST['message_txt'];
    $headers = "From: $e";
    $headers .= "\nReply-To: $e";
    $sentOk = mail($to,$subject,$message,$headers);
    echo "sentOk=" . $sentOk;
    ?>

    Can anyone sniff out why my form isn't working? I'd be very much appreciative. Feel free to email me back at fishercraigj@gmail.com

    Thanks!
    Craig
     
    fishercraigj, Jul 17, 2009 IP
  2. mioot

    mioot Peon

    Messages:
    169
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    hi fishercraigj,
    I checked your code in my server it sending mail perfectly and no error. I checked these in linux server.
     
    mioot, Jul 18, 2009 IP
  3. fishercraigj

    fishercraigj Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Ugh...I guess I might have some sort of a different problem then.
     
    fishercraigj, Jul 18, 2009 IP
  4. vpdesigns

    vpdesigns Peon

    Messages:
    353
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Well fisher i can tell you there is no problem with that code. Im persuming you are using ajax. So i can tell there is a problem with that not the PHP Code that you put above.
     
    vpdesigns, Jul 18, 2009 IP
  5. 3zzy

    3zzy Member

    Messages:
    34
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #5
    See if this helps?
     
    3zzy, Jul 18, 2009 IP
  6. fishercraigj

    fishercraigj Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Well, I've figured out that it's not a server problem...so that's good at least.

    3zzy -
    I went to the link that you sent and it suggest that I use this example:

    <?php
    $to = "fishercraigj@gmail.com";
    $subject = "Hi!";
    $body = "Hi,\n\nHow are you?";
    if (mail($to, $subject, $body)) {
    echo("<p>Message successfully sent!</p>");
    } else {
    echo("<p>Message delivery failed...</p>");
    }
    ?>

    My original code is:

    <?PHP
    $to = "fishercraigj@gmail.com";
    $subject = "CraigFisherLive";
    $e = $_POST['email_txt'];
    $message = "Name: " . $_POST['name_txt'];
    $message .= "\nE-mail: " . $e;
    $message .= "\nPhone: " . $_POST['phone_txt'];
    $message .= "\n\nMessage: " . $_POST['message_txt'];
    $headers = "From: $e";
    $headers .= "\nReply-To: $e";
    $sentOk = mail($to,$subject,$message,$headers);
    echo "sentOk=" . $sentOk;
    ?>

    I'm not a php developer at all so taking my code (came with the template) over to the example that you're showing me, how should it be written?

    Thanks all for the help on this,
    Craig
     
    fishercraigj, Jul 19, 2009 IP
  7. fishercraigj

    fishercraigj Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I'll take a stab though....is this right? If so, it's still not working.

    <?php
    $to = "fishercraigj@gmail.com";
    $subject = "Hi!";
    $body = "Hi,\n\nHow are you?";
    $message = "Name: " . $_POST['name_txt'];
    $message .= "\nE-mail: " . $e;
    $message .= "\nPhone: " . $_POST['phone_txt'];
    $message .= "\n\nMessage: " . $_POST['message_txt'];
    $headers = "From: $e";
    $headers .= "\nReply-To: $e";
    $sentOk = mail($to,$subject,$message,$headers);
    if (mail($to, $subject, $body)) {
    echo("<p>Message successfully sent!</p>");
    } else {
    echo("<p>Message delivery failed...</p>");
    }
    ?>

    I've attached my flash contact page along with the php files in a zip. I'm about 99.9999% sure that the Actionscript is fine but maybe something is wrong with the Actionscript and I'm just missing it.

    PS - If someone helps me solve this, the favor will not go unrecognized. I've got a ton of software (the good stuff) that I'd be willing to help YOU out with. Just my way of returning the favor. :)
     

    Attached Files:

    fishercraigj, Jul 19, 2009 IP
  8. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #8
    You're sending the mail twice or will be once you get it to work. Maybe the line feeds is the problem. Also, $body isn't used >? Did you mean to add it to $message?
    Try this. Replace the last part of your script with this:
    
    $headers = "From: $e \r\n";
    $headers .= "Reply-To: $e";
    $sentOk = mail($to,$subject,$message,$headers);
    if ($sentOk) {
    echo("<p>Message successfully sent!</p>");
    } else {
    echo("<p>Message delivery failed...</p>");
    }
     
    Code (markup):
    Basics of php email and more here :
    http://webcheatsheet.com/php/send_email_text_html_attachment.php
     
    shallowink, Jul 19, 2009 IP
  9. Chemo

    Chemo Peon

    Messages:
    146
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Chemo, Jul 19, 2009 IP