Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Looking for Email Script
Old 01-20-2008, 09:36 PM Looking for Email Script
bigfreak's Avatar
Extreme Talker

Posts: 179
Name: Andy
Trades: 0
Hey gang,

I'm looking to get a spam protected email script for a website.

I've looked around and can't seem to find one that I understand.

Can anybody point me in the right direction?

Thank you in advance for any help!

Here's a code I have found, but i'd like to have it come from the person that filled out the form, and I can't figure out how to add an email field that will send the data.

<?php
if ($_SERVER['REQUEST_METHOD'] != 'POST'){
$me = $_SERVER['PHP_SELF'];
?>
<form name="form1" method="post"
action="<?php echo $me;?>">
<table border="0" cellspacing="0" cellpadding="2">
<tr>
<td>Name:</td>
<td><input type="text" name="Name"></td>
</tr>
<tr>
<td>Subject</td>
<td><input type="text" name="Subject"></td>
</tr>
<tr>
<td valign="top">Message:</td>
<td><textarea name="MsgBody"></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="Submit"
value="Send"></td>
</tr>
</table>
</form>
<?php
} else {
error_reporting(0);
$recipient = 'me@myaddress.com';
$subject = stripslashes($_POST['Subject']);
$from = stripslashes($_POST['Name']);
$msg = "Message from: $from\n\n".stripslashes($_POST['MsgBody']);
if (mail($recipient, $subject, $msg))
echo nl2br("<b>Message Sent:</b>
To: $recipient
Subject: $subject
Message:
$msg");
else
echo "Message failed to send";
}
?>



Last edited by bigfreak; 01-20-2008 at 09:42 PM..
bigfreak is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-20-2008, 09:49 PM Re: Looking for Email Script
Inet411's Avatar
Skilled Talker

Posts: 88
Name: programmer
Location: internet
Trades: 0
PHP Code:
<?php
$to 
'nobody@example.com';
$subject 'the subject';
$message 'hello';
$headers 'From: webmaster@example.com' "\r\n" .
'Reply-To: webmaster@example.com' "\r\n" .
'X-Mailer: PHP/' phpversion();
 
mail($to$subject$message$headers);
?>
__________________

Please login or register to view this content. Registration is FREE

Inet411 is offline
Reply With Quote
View Public Profile Visit Inet411's homepage!
 
Old 01-20-2008, 10:00 PM Re: Looking for Email Script
bigfreak's Avatar
Extreme Talker

Posts: 179
Name: Andy
Trades: 0
Will this cause a problem when i hit reply to the email?

I would be sent back to the website wouldn't it?
bigfreak is offline
Reply With Quote
View Public Profile
 
Old 01-21-2008, 06:31 PM Re: Looking for Email Script
phpknowhow's Avatar
Skilled Talker

Posts: 83
Name: Colin
Location: USA
Trades: 0
Quote:
Originally Posted by bigfreak View Post
I would be sent back to the website wouldn't it?
Not if you changed it around like this:
PHP Code:
  <?php
$from 
$_POST['from'];
$to 'yourself@example.com';
$subject 'the subject';
$message 'hello';
$headers 'From: ' $from "\r\n" .
'Reply-To: ' $from "\r\n" .
'X-Mailer: PHP/' phpversion();
 
mail($to$subject$message$headers);
?>
In order to stop spamming, use an image verification field.
</span>
__________________

Please login or register to view this content. Registration is FREE
| Freelance PHP solutions for small to midsized projects |
Please login or register to view this content. Registration is FREE
phpknowhow is offline
Reply With Quote
View Public Profile Visit phpknowhow's homepage!
 
Reply     « Reply to Looking for Email Script
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.17553 seconds with 12 queries