Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Aug 2009
    Posts
    215
    Thanks
    74
    Thanked 0 Times in 0 Posts

    Send to Friend Fixing Header Mail

    hello

    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.

    PHP Code:
    <?php 

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

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

    ?>
    <html>
    <head>
    <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; };
    </style>
    </head>

    <body>
    <?php

    /* 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">

    </form> 

    <?php
    }

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

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


    outputform();
        } 
        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>";

              
    outputform();
              exit;
        }
          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>";
              
    outputform();
              exit;
        }
        
    $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 {
    outputform();

    ?>
    </body>
    </html>

  • #2
    Regular Coder Zangeel's Avatar
    Join Date
    Oct 2007
    Location
    public_html/
    Posts
    638
    Thanks
    17
    Thanked 79 Times in 79 Posts
    You have something like this in the headers?

    PHP Code:
    $headers "Content-Type: text/plain; charset=UTF-8\n"
    BTW I think ereg is depreciated.
    PHP Code:
    $aString is_string((string)array()) ? true false// true :D 
    [/CENTER]

  • #3
    Regular Coder
    Join Date
    Aug 2009
    Posts
    215
    Thanks
    74
    Thanked 0 Times in 0 Posts
    I tried to make the Sending Line (Mail () function ) like this

    PHP Code:
    $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
    constructed:

    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

  • #4
    Regular Coder Zangeel's Avatar
    Join Date
    Oct 2007
    Location
    public_html/
    Posts
    638
    Thanks
    17
    Thanked 79 Times in 79 Posts
    This is the mail() format:

    PHP Code:
    mail($to$subject$message$headers); 
    Construct it like that
    PHP Code:
    $aString is_string((string)array()) ? true false// true :D 
    [/CENTER]


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •