Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP Mail Form Script - No Email Query

Status
Not open for further replies.

t5amec

Programmer
Aug 14, 2003
112
GB
I am writing a script which sends out emails to people who sign up.

The signees are on an mySQL database, and the script sends the email to each email individually...

Thing is, when it gets to the end of the rows in the DB, instead of it displaying a continue button, which I'd hoped, I get a scary 500 internal error

The code below is what I use as mail.php... please take a look, and let me know if the error is obvious, or in fact it should display what i ask

Code:
<?php
 $id=$_POST["id"];
 $to=$_POST["email"];
 $subject =$_POST["subject"];
 $message=$_POST["message"];
 $from =$_POST["from"];
 $headers = "From: $from";
?>
<?php
if (isset($_POST["email"]))
 {
 mail($to,$subject,$message,$headers);
 echo $to,$subject,$message,$headers;
 echo "<body onLoad='document.tostartmail.submit();'>";
 echo "<form action='start_mail.php' method='post' name='tostartmail'>";
 echo "<input type='text' value='";
 echo $id+0;
 echo "' name='prev_id'>";
 echo "<input type='text' value='";
 echo $from;
 echo "' name='from'>";
 echo "<input type='text' value='";
 echo $subject;
 echo "' name='subject'>";
 echo "<input type='text' value='";
 echo $message;
 echo "' name='message'>";
 echo "<input type='submit'>";
 }
else
 {
 echo "Continue";
 }
?>

</form>
</body>

Make Sense? I hope so (-:
 
why are you using javascript and a browser to submit a form sequentially? why not just send the email sequentially?

but this line should be as shown:

Code:
 $headers = "From: $from [red]\r\n[/red]";

this line is meaningless sfaik, as a comma has no particular function in the echo statement.

Code:
 echo $to,$subject,$message,$headers;

if you enclose it in quotes you might get a better result

Code:
 echo "$to,$subject,$message,$headers";

you are telling the script to use $_POST['email'] but i cannot see such a field in your form. ditto subject. because you are using a conditional, i suspect that nothing will ever happen as $_POST['email'] is never set.

the message field will be limited to 255 characters, as that is the limit of the html text input box. for a greater charlength, use a textarea.

otherwise 500 is an internal server error. quite often these relate to a badly configured php application. for example you would be trying to start mysql from php.ini and not have all the libraries in the right place. i'd recommend ensuring that display_errors and display_startup_errors are turned on in php.ini and that error_reporting is set to E_ALL.

 
ive not heard of an email subsequencer... do you really recommend that?

Make Sense? I hope so (-:
 
i don't know what a sub-sequencer is? i was just recommending sending the emails sequentially from a database without going through a crazy browser submission system.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top