View Full Version : Send to Friend Fixing Header Mail

09-09-2009, 01:46 AM

i use this script to make my visitors send the page they in to a friend and they can include a message too , the problem is the Reciver gets the message with Unknown letters if the email included message in any language if not English , Like Hebrw, Chiness , Arabic..

wht could be done to the script to avoid this problem.


/* Enter the company name or site name here */
$sitename = "my site";

/* Enter the site web address */
$siteaddress = "http://www.domain.com/";

<meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
<title>Send to Friend</title>
<!--<link href="default.css" rel="stylesheet" type="text/css" /> Uncomment this line if you have a CSS file you wish to use -->
<style type="text/css">
/* Some example styles, amend or remove as needed */
BODY{background-color:#D1EB76; color:#809F0A; font-family: verdana, helvetica, sans-serif; font-size:14px; font-weight:bold;}
FONT{color:#FF9900; font-size:14px; font-weight:bold; font-family: verdana, helvetica, sans-serif; background-color:#CCFF33; }
A:Visited{color:#CCCC00; }
A:Hover{color:#FFFF66; }
label { float: right; clear: both; }
TextInput {
backgroundColor: #99cc00;
color: #003300;
borderStyle: inset;
borderColor: #669900;
borderThickness: 1;
cornerRadius: 2;
textIndent: 7;
dropShadowEnabled: false;

NumericStepper {

ComboBox {

CheckBox {

RadioButton {

HSlider {
#yemail, #yname, #femail, #fname, #captcha_num, #comments { width: 300px; border: 1px solid #008000; background: #CCFF66; }
#submit { margin-top: 1em; };


/* Do not edit below this line unless you know what you're doing */

$yname = $_POST['yname'];
$yemail = $_POST['yemail'];
$femail = $_POST['femail'];
$comments = $_POST['comments'];
$pageurl = $_POST['loc'];

function outputform() {

$pageurl = htmlentities($_GET['loc']);
//$pageurl = $_SERVER['HTTP_REFERER'];
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
<form method="post">
<label for="yname">Name:</label>
<input type="text" name="yname"dir="rtl" id="yname" value="<?php echo "$_POST[yname]"; ?>" />

<label for="yemail">Email:</label>
<input type="text" name="yemail" id="yemail" value="<?php echo "$_POST[yemail]"; ?>" />

<label for="femail">Your friend Email:</label>
<input type="text" name="femail" id="femail" value="<?php echo "$_POST[femail]"; ?>" />

<label for="comments"> Comment: </label>
<textarea name="comments" rows="3" id="comments"dir="rtl"><?php echo "$_POST[comments]"; ?></textarea>

<input type="hidden" id="loc" name="loc" value="<?php echo "$pageurl"; ?>" />

<input type="submit" id="submit" name="submit" value="Send Now" style="float: right">



if ($_POST['submit']) {
if (($yname=="") || ($femail=="")|| ($yemail=="")) {

print "<p><font size=\"12px\" color=\"red\"><strong></strong>Fill All Fileds</font></p>";

else {
if (!eregi("^[a-z0-9]+([-_\.]?[a-z0-9])+@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z]{2,4}", $yemail)) {
print "<p><font size=\"12px\" color=\"red\"><strong>Your Email Not Ok</strong></font></p>";

if (!eregi("^[a-z0-9]+([-_\.]?[a-z0-9])+@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z]{2,4}", $femail)) {

print "<p><font size=\"12px\" color=\"red\"><strong>Error :</strong>Your friend Email Not Ok</font></p>";
$comments = stripslashes($comments);
mail("$femail","$yname Your friend $sitename","\n\n$yname wants you to see this link $sitename \n\nURL: $pageurl \n\n he left you this message\n------------------------------------ \n$comments \n------------------------------------\n\n $sitename ($siteaddress)","From:$yemail");
echo "<p>$femail<strong>Sent to</strong> </p><p><a href=\"javascript:window.close()\">Close</a></p>";
else {

09-09-2009, 03:11 AM
You have something like this in the headers?

$headers = "Content-Type: text/plain; charset=UTF-8\n";

BTW I think ereg is depreciated.

09-09-2009, 05:07 AM
I tried to make the Sending Line (Mail () function ) like this

$headers = "Content-Type: text/plain; charset=UTF-8\n";
mail("$femail","$yname you friend $sitename","\n\n$yname saw this $sitename \n\nURL: $pageurl \n\n left u this message \n------------------------------------ \n$comments \n------------------------------------\n\n $sitename ($siteaddress)","From:$yemail",$headers);

But did not work the email Returns to me with this error

A message that you sent contained a recipient address that was incorrectly

Content-Type: missing or malformed local part (expected word or "<")

The message has not been delivered to any recipients.

i belive the error has to do somthing in where i placed the $headers

09-09-2009, 06:17 AM
This is the mail() format:

mail($to, $subject, $message, $headers);

Construct it like that

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum