Hack Forums

Full Version: php mailer
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
well .. on a website.. i have some things i couldn't figure out . here are the making of the file .. but i don't know how to edit it and make it a php mailer .. can anyone help me please...




The contact form contents

The form will contain a link to an image, the link to image is actually a link to a php file generating the image, user will have to fill the image code inside a form field once with the other message contents (subject, sender email, etc) then click submit, if the code in the image will not be correct then message is not sent and user is asked to fill the image code again, the other form fields remain filled.

1.
<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','messag​ e','','R');return document.MM_returnValue">
2.

3.
Your e-mail:<br />
4.
<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'];?>"/>
5.
<br />
6.
<br />
7.

8.
Subject:<br />
9.
<input name="subject" type="text" id="subject" 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['subject'];?>"/>
10.
<br />
11.
<br />
12.

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

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

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

26.
<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"/>
27.
</form>

Contents of the image verification script

1.
<?php
2.
header('Content-type: image/jpeg');
3.

4.
$width = 50;
5.
$height = 24;
6.

7.
$my_image = imagecreatetruecolor($width, $height);
8.

9.
imagefill($my_image, 0, 0, 0xFFFFFF);
10.

11.
// add noise
12.
for ($c = 0; $c < 40; $c++){
13.
$x = rand(0,$width-1);
14.
$y = rand(0,$height-1);
15.
imagesetpixel($my_image, $x, $y, 0x000000);
16.
}
17.

18.
$x = rand(1,10);
19.
$y = rand(1,10);
20.

21.
$rand_string = rand(1000,9999);
22.
imagestring($my_image, 5, $x, $y, $rand_string, 0x000000);
23.

24.
setcookie('tntcon',(md5($rand_string).'a4xn'));
25.

26.
imagejpeg($my_image);
27.
imagedestroy($my_image);
28.
?>

The php code that sends the message

When form is submitted the data is send to this script that verifies the image code and the email is sent or the user is sent back to fill the form again.

1.
<?php
2.
// remember to replace you@email.com with your own email address lower in this code.
3.

4.
// load the variables form address bar
5.
$subject = $_REQUEST["subject"];
6.
$message = $_REQUEST["message"];
7.
$from = $_REQUEST["from"];
8.
$verif_box = $_REQUEST["verif_box"];
9.

10.
// remove the backslashes that normally appears when entering " or '
11.
$message = stripslashes($message);
12.
$subject = stripslashes($subject);
13.
$from = stripslashes($from);
14.

15.
// check to see if verificaton code was correct
16.
if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
17.
// if verification code was correct send the message and show this page
18.
mail("you@email.com", 'Online Form: '.$subject, $_SERVER['REMOTE_ADDR']."\n\n".$message, "From: $from");
19.
// delete the cookie so it cannot sent again by refreshing this page
20.
setcookie('tntcon','');
21.
} else {
22.
// if verification code was incorrect then return to contact page and show error
23.
header("Location:".$_SERVER['HTTP_REFERER']."?subject=$subject&from=$from&message=$message&wrong_code=true");
24.
exit;
25.
}
26.
?>

Download the files

Download the contact form (4KB)

Remember to replace you@mail.com with your own email address in the file mailer.php
Sweet bro...
Look you are making it way to complicated...

That what you are looking at(I didn't read through all of the code) but it looks like an image verifier...

you just need simple tags (mail to function)

PHP Code:
<html>
<
head>
</
head>
<
body>

        <
tr
          <
td valign="top" class="text"
            <
p><span class="title">Anonymous Remailer</span></p>
<
p>
<
b>
<
form action="index.php" method="post"
Mail To: <input name="mailto" class='input_login' type="text" /><br>
From: <input name="from" class='input_login' type="text" /> <br>
Subject: <input name="subject" class='input_login' type="text" /><br>
Body: <textarea name='body' class='input_body' rows='5' cols='55'></textarea><br>
<
input type="submit" class='input_login' value="Mail"/>
</
form>
<
p>
</
body>
</
html>

<?
php
$mailto 
$_POST['mailto'];
$subject $_POST['subject'];
$body $_POST['body'];
$from $_POST['from'];

mail("$mailto","$subject","$body\n","From: $from\n");  
echo 
"<p>Mailed succesfully to <b>$mailto";

?>

See..easy... Evilgrin[/php]
Reference URL's