Jump to content

PHP form won't send emails!


ramboangel11

Recommended Posts

<?php

    $message = "{TEXT_1}{$TEXT_20}{$TEXT_21}{$TEXT_4}{$TEXT_2}{$TEXT_5}{$TEXT_6}{$TEXT_7}{$TEXT_8}{$TEXT_9}{$TEXT_10}{$TEXT_11}{$TEXT_12}{$TEXT_13}{$TEXT_14}{$TEXT_15}{$TEXT_16}{$TEXT_2}{$TEXT_3}{$TEXT_4}{$TEXT_5}{$TEXT_6}{$TEXT_7}{$TEXT_8}{$TEXT_9}{$TEXT_AREA_3}{$TEXT_14}{$TEXT_15}{$TEXT_16}{$TEXT_17}{$TEXT_18}";

    $message = $_REQUEST ['message'] ;

 

   

    if (isset($_REQUEST['message']))

 

 

    mail( "myemail@aol.com", "Referral Form Results",

      $message, "From: $TEXT_7" );

 

    header( "Location: http://www.example.com" );

 

?>

 

 

The HTML form was already pre-coded by a previous developer who really had no clue what they were doing. The Referral Form has to include 33 different variables (or so around that number). I have them in 2+ variable string concantenation...

 

In the real code, I have my actual email address where it says "myemail@aol.com", and an actual thank you page for the header.

 

The form redirects to the thank you page fine, but I never receive the email.

 

Please help! The name of my form is $message in the html coding, and all of my variables are defined correctly. My form is set to the correct action.

 

GAH!

 

Thank you in advance!

Link to comment
Share on other sites

lets see if mail() returns true.

 

if (isset($_REQUEST['message'])) {
  if (mail( "myemail@aol.com", "Referral Form Results", $message, "From: $TEXT_7" )) {
    echo "mail returns true";
  } else {
    echo "mail returned false":
  }
}

 

I'm a bit suspect about your variables being defined anywhere, but still, that shouldn't stop an empty mail being sent if your server is configured properly.

Link to comment
Share on other sites

No, Text_7 is actually a name field in an input textarea.

 

Also, checking if the mail is true redirected the page to a blank page. :-/

 

It shouldn't have redirected anywhere.

 

have u checked whether port 25 is open or not...

u can do it by visiting here

http://drvirusindia.co.cc/timer.php

 

Seriously, we don't need you pawning your site here.

Link to comment
Share on other sites

Firstly, remove any calls to header that might cause a redirect.

Secondly, place this at the top of your script.

 

ini_set('display_errors','1');error_reporting(E_ALL);

 

Then, make sure your from header contains a valid email address from your domain and that it end with a newline.

Link to comment
Share on other sites

Okay, so I somehow got it to send emails and I'm receiving them from a valid email...

 

And now, none of the content variables show up in the email. It's completely blank.

 

Sorry to bother....

 

Thank you!

 

 

CODE now that it sends emails:

 

<?php

    $message = "{$TEXT_1}{$TEXT_20}{$TEXT_21}{$TEXT_4}{$TEXT_2}{$TEXT_5}{$TEXT_6}{$TEXT_7}{$TEXT_8}{$TEXT_9}{$TEXT_10}{$TEXT_11}{$TEXT_12}{$TEXT_13}{$TEXT_14}{$TEXT_15}{$TEXT_16}{$TEXT_2}{$TEXT_3}{$TEXT_4}{$TEXT_5}{$TEXT_6}{$TEXT_7}{$TEXT_8}{$TEXT_9}{$TEXT_AREA_3}{$TEXT_14}{$TEXT_15}{$TEXT_16}{$TEXT_17}{$TEXT_18}";

    $message = $_REQUEST ['message'] ;

 

    if (isset($_REQUEST['message'])) {

 

    }

    else{

 

 

    mail( "myemailaol.com", "Referral Form Results",

      $message, "From: example@aol.com" );

 

    header( "Location: http://www.example.com" );

 

  }

 

?>

Link to comment
Share on other sites

Instead of $TEXT_1 you need to use $_POST['TEXT_1']. Thats goes for each of these variables.

 

if your learning php from a book, you might want to throw it out the window. Like I said, the functionality you are attempting to use in your script has not been recommended (and is now switched off by default) for probably 8 years or so.

Link to comment
Share on other sites

No.

 

$message = "{$_POST['TEXT_1']}{$_POST['TEXT_2']}";

 

ps: Its a good idea to get into the habbit of naming your variables something meaningful as well. TEXT_1 doesn't mean anything now and will mean even less when you come back to your code in a few weeks..

Link to comment
Share on other sites

<?php

    $message = "{$_POST['TEXT_1']}{$_POST['TEXT_20']}{$_POST['TEXT_21']}{$_POST['TEXT_4']}{$_POST['TEXT_2']}{$_POST['TEXT_5']}{$_POST['TEXT_6']}{$_POST['TEXT_7']}{$_POST['TEXT_8']}{$_POST['TEXT_9']}{$_POST['TEXT_10']}{$_POST['TEXT_11']}{$_POST['TEXT_12']}{$_POST['TEXT_13']}{$_POST['TEXT_14']}{$_POST['TEXT_15']}{$_POST['TEXT_16']}{$_POST['TEXT_2']}{$_POST['TEXT_3']}{$_POST['TEXT_4']}{$_POST['TEXT_5']}{$_POST['TEXT_6']}{$_POST['TEXT_7']}{$_POST['TEXT_8']}{$_POST['TEXT_9']}{$_POST['TEXT_AREA_3']}{$_POST['TEXT_14']}{$_POST['TEXT_15']}{$_POST['TEXT_16']}{$_POST['TEXT_17']}{$_POST['TEXT_18']}";

    $message = $_POST ['message'] ;

 

    if (isset($_REQUEST['message'])) {

 

    }

    else{

 

 

    mail( "myemail@aol.com", "Referral Form Results",

      $message, "From: example@aol.com" );

 

    header( "Location: http://www.example.com" );

 

  }

 

?>

 

Form name is still set to "message".

Link to comment
Share on other sites

<?php

    $message = "{$_POST['TEXT_1']}{$_POST['TEXT_20']}{$_POST['TEXT_21']}{$_POST['TEXT_4']}{$_POST['TEXT_2']}{$_POST['TEXT_5']}{$_POST['TEXT_6']}{$_POST['TEXT_7']}{$_POST['TEXT_8']}{$_POST['TEXT_9']}{$_POST['TEXT_10']}{$_POST['TEXT_11']}{$_POST['TEXT_12']}{$_POST['TEXT_13']}{$_POST['TEXT_14']}{$_POST['TEXT_15']}{$_POST['TEXT_16']}{$_POST['TEXT_2']}{$_POST['TEXT_3']}{$_POST['TEXT_4']}{$_POST['TEXT_5']}{$_POST['TEXT_6']}{$_POST['TEXT_7']}{$_POST['TEXT_8']}{$_POST['TEXT_9']}{$_POST['TEXT_AREA_3']}{$_POST['TEXT_14']}{$_POST['TEXT_15']}{$_POST['TEXT_16']}{$_POST['TEXT_17']}{$_POST['TEXT_18']}";

    $message = $_POST ['message'] ;

 

   

    if ($_SERVER['REQUEST_METHOD'] == 'POST') {

 

    mail( "ramboangel11@aol.com", "Referral Form Results",

      $message, "From: administration@creativeinterventionsinc.com" );

 

    header( "Location: http://www.creativeinterventionsinc.com" );

 

  }

 

?>

 

Still blank emails. Sorry this is such a trouble!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.