Mail script not working

You forgot to click in the formmail.php, and then click the payload tab like @m_hutley susgested. Then post here the image

OK, here it is, the “t’s” was what I entered into the form.

So that definitely says that the form is sending the data (I assume you put “t” in all of the fields)… why then would PHP not be receiving it… hrm.

Just one thing I want to confirm: the php script is in the same server folder as the form page, right?

Your form is sending the data here.

That got to be it. Is working for me in my local computer.

localhost 8000? Where does that come from?

I am running locally and port 8000. You have to point to your server and the correct port

Ok. I pointed to your server and worked for me.

Change this:

<form method="POST" action="http://www.bmrealty.com/formmail.php">

to this:

<form method="POST" action="https://www.bmrealty.com/formmail.php">

:crossed_fingers:

Tried it, this is what I see:

PHPFormMail has experienced errors that must be fixed by the webmaster. Mail will NOT be sent until these issues are resolved. Once these issues are resolved, you will have to resubmit your form to PHPFormMail for the mail to be sent.

Well, change is progress! At least it means the script got to the point of parsing the text.

Does this array contain the domain that the form is on? Does this array contain the domain that the email is being sent to?

Also something tells me that you should be defining a recipient and key. I can’t imagine a production site where you would let someone insert a recipient’s address.

OK guys, here’s the entire form and the top of the script:

<form method="POST" action="https://www.bmrealty.com/formmail.php">
<input type="hidden" name="env_report" value="www.bmrealty.com" />
<input type="hidden" name="recipient" value="bm@bmrealty.com">
<table border="0" cellpadding="0" cellspacing="0" width="400" align="center"><tr>
<td width="400" align="right" valign="middle" class="c13">Your Name:&nbsp;&nbsp;<input type="text" size="40" maxlength="60" name="Name">&nbsp;&nbsp;&nbsp;</td>
</tr><tr>
<td width="400" align="right" valign="middle" class="c13">Phone:&nbsp;&nbsp;<input type="text" size="40" maxlength="60" name="Phone">&nbsp;&nbsp;&nbsp;</td>
</tr><tr>
<td width="400" align="right" valign="middle" class="c13">E-mail:&nbsp;&nbsp;<input type="text" size="40" maxlength="60" name="E-mail">&nbsp;&nbsp;&nbsp;</td>
</tr><tr>
<td class="c13" align="center" valign="middle"><br><b>Enter any additional information you wish<br> in the space provided below:</b>
<br><textarea name="Additional Information" rows="5" cols="50"></textarea>
<br>
<input type="SUBMIT" value="Send to Brigitte">&nbsp;&nbsp;&nbsp;<input type="RESET" value="Start Over"></td></tr></table>
</form>

/ To change the address the e-mail comes from use define('FROM', 'Example Name <email@example.com>');
define('FROM', null);

$referers = array('http://www.bmrealty.com', 'bmrealty.com');

// $recipient_array format is $recipient_array = array('sometext'=>'email@example.com','asdf'=>'email2@example.com');
$recipient_array = array();

$valid_env = array('www.bmrealty.com');

// +------------------------------------------------------------------------+
// | STOP EDITING! The only two required variables that need to be updated  |
// | are $referers and $valid_env                                           |
// +------------------------------------------------------------------------+

And?. You are getting the same error?

Right now I’m getting this error: * Sorry, but I cannot figure out who sent you here. Your browser is not sending an HTTP_REFERER. This could be caused by a firewall or browser that removes the HTTP_REFERER from each HTTP request you submit.

Okay… before… we go too much further. Let’s try attacking this a different way.

Your goal, put simply, is:

  • Take form input
  • Send form input to an email.
    You have confirmed that:
  • The host is capable of sending mail.
  • The host has PHP, at least version 7, if not 8+.

Am I correct?

(For those who are helping out, yes, my intention at this point is to say screw it, here’s a PHPMailer script that will do what you tell it to do.)

Yes to all!

Remove this code:

    if (CHECK_REFERER == true) {
        check_referer($referers);
    } else {
        error_log('[PHPFormMail] HTTP_REFERER checking is turned off.  Referer: ' . $_SERVER['HTTP_REFERER'] . '; Client IP: ' . $_SERVER['REMOTE_ADDR'] . ';', 0);
    }

Okay. Let’s try this. Something tried-and-tested for most of us here…

<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';

$mail = new PHPMailer(true);
try {
  $mail->setFrom('bm@bmrealty.com', 'Form Mail Handler');
  $mail->addAddress('bm@bmrealty.com');   
  $mail->addReplyTo($_POST['E-mail'], 'Information');
  $mail->isHTML(true);                                  //Set email format to HTML
  $mail->Subject = 'Here is the subject';
  $mail->Body    = '<ul><li>Name:'.$_POST['Name']."</li><li>Phone: ".$_POST['Phone']."</li><li>Email: ".$_POST['E-mail']."</li></ul>";
  $mail->AltBody = "Name: ".$_POST['Name']." | Phone: ".$_POST['Phone']." | Email: ".$_POST['E-mail'];
  $mail->send();
    echo 'Message has been sent';
} catch (Exception $e) {
    echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
?>
  • Change your form to point at action="formhandle.php"
  • Test the form. See what Happens.

Most of us are much more familiar with PHPMailer, and it’s an actively maintained system, last version released last year, rather than 2007.

(Also, yes, before i get yelled at by other experts; i know i’m using the POST variables unfiltered. This is a baseline “does it work”. Will add security refinements once we actually see a mail come through.)

Browser says “Message has been sent”.
Mail has actually arrived! :joy:

I can’t believe it, it seems to work! It’s alive!!!

2 Likes