WEB sending an email through a webpage form v.other languages

Discussion in 'OT Technology' started by MSTRMOO, Apr 29, 2008.

  1. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
    when i try to send a message through a webpage form (php) in russian, the email comes as something like "екÑандра ÐлекÑандра ÐлекÑ"

    is there anything i can do about that?
     
  2. biawokauns

    biawokauns New Member

    Joined:
    Sep 18, 2001
    Messages:
    19,893
    Likes Received:
    0
    Location:
    Republic of Kalifornia
    encode it in UTF8
     
  3. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
    how do i do that? :confused: i got the script from a generator.. it looks like this:

    Code:
    <?php
    
    
    // get posted data into local variables
    $EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); 
    $EmailTo = "***@*****.com";
    $Subject = "Inquiry";
    $FirstName = Trim(stripslashes($_POST['FirstName'])); 
    $LastName = Trim(stripslashes($_POST['LastName'])); 
    $Phone = Trim(stripslashes($_POST['Phone'])); 
    $Message = Trim(stripslashes($_POST['Message'])); 
    
    // validation
    $validationOK=true;
    if (Trim($EmailFrom)=="") $validationOK=false;
    if (!$validationOK) {
      print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
      exit;
    }
    
    // prepare email body text
    $Body = "";
    $Body .= "FirstName: ";
    $Body .= $FirstName;
    $Body .= "\n";
    $Body .= "LastName: ";
    $Body .= $LastName;
    $Body .= "\n";
    $Body .= "Phone: ";
    $Body .= $Phone;
    $Body .= "\n";
    $Body .= "Message: ";
    $Body .= $Message;
    $Body .= "\n";
    
    // send email 
    $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
    
    // redirect to success page 
    if ($success){
      print "<meta http-equiv=\"refresh\" content=\"0;URL=thank_you2.html\">";
    }
    else{
      print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
    }
    ?>
     
  4. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
  5. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
    would putting something like:

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    at the top of the page be enough?
     
  6. Vailripper

    Vailripper Daywalkers have feelings too.

    Joined:
    Jan 25, 2006
    Messages:
    6,170
    Likes Received:
    0
    Location:
    Bellingham, WA
  7. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
    that kinda helps.. but i'm unfamiliar with all of this.. could you give me an example of how i would use it with the above script?
     
  8. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
    anyone?
     
  9. lukin87

    lukin87 New Member

    Joined:
    Jan 11, 2008
    Messages:
    135
    Likes Received:
    0
    google it mang.
     
  10. noon

    noon get high and teach me how to listen

    Joined:
    May 4, 2002
    Messages:
    3,384
    Likes Received:
    0
    Location:
    Lawrence, KS
    Code:
    <?php
    
    	/* 	AIM: n00n		*/
    	
    	/*	FROM-EMAIL POST	*/
    	$e_from = isset($_POST['EmailFrom'])?trim(stripslashes(utf8_encode($_POST['EmailFrom']))):''; 
    	
    	/*	FROM-EMAIL VALIDATION	*/
    	if ($e_from=='')
    		@header('error.htm');
    	
    	/*	IF YOU ARE SENDING TO U.S. EMAIL,
    		USE THIS INSTEAD	
    		if (! preg_match(	"/^([a-z0-9]([a-z0-9_-]*\.?[a-z0-9])*)(\+[a-z0-9]+)?@" .
    							"([a-z0-9]([a-z0-9-]*[a-z0-9])*\.)*([a-z0-9]([a-z0-9-]*" .
    							"[a-z0-9]+)*)\.[a-z]{2,6}$/i", 
    							$e_from
    						)
    			)
    			@header('error.htm');	*/
    	
    	/* REMAINING POST */
    	$e_to = utf8_encode("***@*****.com");
    	$e_sub = utf8_encode("Inquiry");
    	$e_fname = isset($_POST['FirstName'])?trim(stripslashes(utf8_encode($_POST['FirstName']))):''; 
    	$e_lname = isset($_POST['LastName'])?trim(stripslashes(utf8_encode($_POST['LastName']))):''; 
    	$e_phone = isset($_POST['Phone'])?trim(stripslashes(utf8_encode($_POST['Phone']))):''; 
    	$e_msg = isset($_POST['Message'])?stripslashes(utf8_encode($_POST['Message'])):'';
    	
    	/* PREPARE BODY */
    	$e_body =	"First Name: $e_fname \n" .
    			"Last Name: $e_lname \n" .
    			"Phone: $e_phone \n" .
    			"Message: $e_msg \n";
    	
    	/* SEND EMAIL */
    	if (mail($e_to, $e_sub, $e_body, "From: <$e_from>"))
    		@header('thank_you2.html');
    	
    	@header('error.htm');
    
    ?>
    
    here
     
  11. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
    :bowdown: thanks for taking the time..

    unfortunatly im getting this:

    Internal Server Error
    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

    More information about this error may be available in the server error log.



    i also tried using the part you labeled as "IF YOU ARE SENDING TO U.S. EMAIL, USE THIS INSTEAD" (it is being sent to a US address btw) with the same result..

    the emails however ARE being sent, but still encoded wrong :hs:
     
  12. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
    WOW ok heres the deal............ when i use the code i posted above with NO utf8_encode and check my webbased GMAIL inbox.. everything looks fine... but in outlook, i get the symbols....... so i guess its an outlook issue then? i tried changeing the encoding within outlook with no luck..
     
  13. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
    omg.. ok i figured it out
     

Share This Page