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( "[email protected]", "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 "[email protected]", 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
https://forums.phpfreaks.com/topic/185182-php-form-wont-send-emails/
Share on other sites

lets see if mail() returns true.

 

if (isset($_REQUEST['message'])) {
  if (mail( "[email protected]", "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.

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.

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.

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: [email protected]" );

 

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

 

  }

 

?>

<input name="TEXT_1" maxlength=255 size=1 value="" type=text>

 

This is inside the .htm document. The same code for each separate variable.

 

<form name="message" method="post" action="sendmail2.php">

This is my form tag in the same .htm document.

 

>.<

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.

<?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( "[email protected]", "Referral Form Results",

      $message, "From: [email protected]" );

 

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

 

  }

 

?>

 

Form name is still set to "message".

<?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( "[email protected]", "Referral Form Results",

      $message, "From: [email protected]" );

 

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

 

  }

 

?>

 

Still blank emails. Sorry this is such a trouble!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.