PDA

View Full Version : Can somebody take a look at my form mail script...



sg552
July 27th, 2008, 05:21
Hello everyone, can anyone take a look at this script, it's not sending any email.... :(


<?php

//Bring in the PHPMailer class
require("class.phpmailer.php");

//Create a new mail object. You'll get an error here is the right files are not required
//at the top of this script.
$mail = new phpmailer();
// set mailer to use SMTP
$mail->IsSMTP();
//Specify the use of the local server.
//Should not have to authenticate.
//If you get an error sending, use the Christian-Web-Masters.com forums to ask
//How to change this script to use another server.
//Or read the documentation for PHPMailer.
$mail->Host = "localhost";

// -----------------------------------------
// The Web Help .com
// -----------------------------------------

// load the variables form address bar
$to = $_REQUEST["to"];
$to = preg_replace("/[^a-zA-Z0-9@._-]/", "", $to);

$to = explode(",",$to);
$to = $to['0'];




// remove the backslashes that normally appears when entering " or '
$to = stripslashes($to);
$message = stripslashes($message);
$subject = stripslashes($subject);
$sendname = stripslashes($sendname);
$from = stripslashes($from);

// check to see if verificaton code was correct
if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
// if verification code was correct send the message and show this page

$mail->From = $_POST['from'];
$mail->FromName = $_POST['sendname'];
$mail->AddAddress = $_POST['to'];
$mail->Subject = $_POST['subject'] . $subject;
$mail->Body = $_POST['message'] . "\r\n" . $_POST['message']
. "\n\n" .
$mail->Send()

$defaultMessageClose;


// delete the cookie so it cannot sent again by refreshing this page
setcookie('tntcon','');
} else {
// if verification code was incorrect then return to contact page and show error
header("Location:http://www.mydomain.com/temp/?wrong_code=true");
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>E-Mail Sent</title>
<style type="text/css">
<!--
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
-->
</style></head>

<body>
Email sent. Thank you.<br />
<br />
Return to <a href="/">home page</a> ?
</body>
</html>
This script use SMTP and after I input all the detail and click send, I get this error.


Parse error: syntax error, unexpected T_STRING in /home/kilot/public_html/mydomain/temp/mailer.php on line 53

This script use some spam filter (regex??) and captchas.

Please help me and thanks in advance :P

JonnyH
July 27th, 2008, 05:47
You forgot your semi colon on the send. Plus, I removed that variable just sat there, did nothing.

<?php

//Bring in the PHPMailer class
require("class.phpmailer.php");

//Create a new mail object. You'll get an error here is the right files are not required
//at the top of this script.
$mail = new phpmailer();
// set mailer to use SMTP
$mail->IsSMTP();
//Specify the use of the local server.
//Should not have to authenticate.
//If you get an error sending, use the Christian-Web-Masters.com forums to ask
//How to change this script to use another server.
//Or read the documentation for PHPMailer.
$mail->Host = "localhost";

// -----------------------------------------
// The Web Help .com
// -----------------------------------------

// load the variables form address bar
$to = $_REQUEST["to"];
$to = preg_replace("/[^a-zA-Z0-9@._-]/", "", $to);

$to = explode(",",$to);
$to = $to['0'];




// remove the backslashes that normally appears when entering " or '
$to = stripslashes($to);
$message = stripslashes($message);
$subject = stripslashes($subject);
$sendname = stripslashes($sendname);
$from = stripslashes($from);

// check to see if verificaton code was correct
if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
// if verification code was correct send the message and show this page

$mail->From = $_POST['from'];
$mail->FromName = $_POST['sendname'];
$mail->AddAddress = $_POST['to'];
$mail->Subject = $_POST['subject'] . $subject;
$mail->Body = $_POST['message'] . "\r\n" . $_POST['message']
. "\n\n" .
$mail->Send();
// delete the cookie so it cannot sent again by refreshing this page
setcookie('tntcon','');
} else {
// if verification code was incorrect then return to contact page and show error
header("Location:http://www.mydomain.com/temp/?wrong_code=true");
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>E-Mail Sent</title>
<style type="text/css">
<!--
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
-->
</style></head>

<body>
Email sent. Thank you.<br />
<br />
Return to <a href="/">home page</a> ?
</body>
</html>

sg552
July 27th, 2008, 06:15
This line executed


Email sent. Thank you.

Return to home page ?

but I still don't receive the email. Both my inbox and spambox is empty :confused4 why is that..??

Thank for your help :P

JonnyH
July 27th, 2008, 06:17
I don't have a clue, I can't see the email class. It may be due to your server.

sg552
July 27th, 2008, 06:31
This is my index.php Just cut and paste the important code...


<form action="mailer.php" method="post" name="form1" id="form1" style="margin:0px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px; width:300px;" onsubmit="MM_validateForm('from','','RisEmail','subject','','R','verif _box','','R','message','','R');return document.MM_returnValue">

Sender's name:<br />
<input name="sendname" type="text" id="sendname" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:14px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;" value="<?php echo $_GET['sendname'];?>"/>
<br />
<br />

Sender's e-mail:<br />
<input name="from" type="text" id="from" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:14px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;" value="<?php echo $_GET['from'];?>"/>
<br />
<br />

Recepient's e-mail:<br />
<input name="to" type="text" id="to" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:14px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;" value="<?php echo $_GET['to'];?>"/>
<br />
<br />

Subject:<br />
<input name="subject" type="text" id="subject" style="padding:2px; border:1px solid #CCCCCC; width:300px; height:14px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;" value="<?php echo $_GET['subject'];?>"/>
<br />
<br />

Message:<br />
<textarea name="message" cols="6" rows="5" id="message" style="padding:2px; border:1px solid #CCCCCC; width:460px; height:170px; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;"><?php echo $_GET['message'];?></textarea>
<br />
<br />

Type verification image:<br />
<input name="verif_box" type="text" id="verif_box" style="padding:2px; border:1px solid #CCCCCC; width:132px; height:14px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;"/>
<img src="verificationimage.php?<?php echo rand(0,9999);?>" alt="verification image, type it in the box" width="50" height="24" align="absbottom" /><br />
<br />

<!-- if the variable "wrong_code" is sent from previous page then display the error field -->
<?php if(isset($_GET['wrong_code'])){?>
<div style="border:1px solid #990000; background-color:#D70000; color:#FFFFFF; padding:4px; padding-left:6px;width:295px;">Wrong verification code</div><br />
<?php ;}?>

<input name="Submit" type="submit" style="margin-top:10px; display:block; border:1px solid #000000; width:100px; height:20px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; padding-left:2px; padding-right:2px; padding-top:0px; padding-bottom:2px; line-height:14px; background-color:#EFEFEF;" value="Send Message"/>
</form>

Not the whole code and I think I have no error here. Do tell me if you see any error. Thanks for your help :-)

JonnyH
July 27th, 2008, 06:32
That code doesn't matter, to see I would need this:

class.phpmailer.php

sg552
July 27th, 2008, 06:51
I get this error...

The text that you have entered is too long (51856 characters). Please shorten it to 20000 characters long.

Please visit this link >>

http://seapanel.co.cc/index.txt

I don't change any code in this phpmailer. I get this for free. Infact I test it with the script from here http://phpmailer.codeworxtech.com/index.php?pg=tutorial it's works perfect. So my webhosting provider is not the problem right?? :)

Thanks in advance :)