I want to send a html mail with multi-language (german, russian, turkish )in php.
Some part of mail content is from database. And some part user have to enter.
My database is ok. And Unicode utf-8 is used.
When I am retrieving data from database to my web page is ok. And coming in Russian language,
But when I am using same content to send email, the content comes with Unicode character but not in Russia language
I want mail in german, russian, turkish language.
In result Im am getting mail in htm format But thih some unicode charecters

This is not the full email But the part of its body text
output of mail content is ----------------------------------

Академия Федерального агентства Правительственной связи и информации при президенте Российской Федерации

Имя пользователя # из # имя вуза # пригласил тебя в


This is a part of code of mail page (sendmail.php) code of page is working properly.
In that page I used
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
inside html header tag

my mail code is as follows-------------

<?
$message = "
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
</head>
<body>

<table width='600' border='0' align='left' cellpadding='0' cellspacing='0'>
<tr valign='top'>
<td align='left'><!--header Section Start here-->
<table width='100%' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td height='35' align='left' bgcolor='#3b5998' style='font-size:14px; color:#FFFFFF; font-family:Arial'> $mail1_invitationsent $mail2_invitationsent</td>
</tr>
</table>
<!--header Section end here here-->
</td>
</tr>
<tr>
<td height='20' colspan='2' align='left' bgcolor='#6d84b4' style='font-size:14px; color:#FFFFFF; font-family:Arial; font-style:italic'> $mail3_invitationsent ($college_name)</td>
</tr>
<tr>
<td><table width='600' align='center' cellspacing='0' cellpadding='0' style='BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; BORDER-LEFT: 1px solid; border-bottom: 1px solid; border-top-color:#6d84b4; border-right-color:#6d84b4; border-left-color:#6d84b4; border-bottom-color:#6d84b4' >
<tr>
<td><!--Page body Section Start here-->
<table width='600' border='0' align='center' cellpadding='0' cellspacing='0'>
<tr>
<td valign='top'>
<table width='100%' border='0' align='center' cellpadding='0' cellspacing='0'>
<tr>
<td colspan='3'></td>
</tr>
<tr>
<td width='2%'> </td>
<td colspan='2' align='left' style='font-size:12px; font-family:Arial'>$mail_contents</td>
</tr>
<tr>
<td rowspan='5'> </td>
<td height='10' align='left' style='font-size:12px; font-family:Arial'></td>
<td width='37%' rowspan='5' align='left'> </td>
</tr>
<tr>
<td width='61%' height='8' align='left' style='font-size:12px; font-family:Arial'>$mail4_invitationsent </td>
</tr>
<tr>
<td height='10'></td>
</tr>
<tr>
<td height='8' align='left' style='font-size:12px; font-family:Arial'>$mail5_invitationsent </td>
</tr>
<tr>
<td align='left' valign='top' style='font-size:12px; font-family:Arial'></td>
</tr>
<tr>
<td colspan='3'> </td>
</tr>
</table>
</td>
</tr>
</table>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td height='3'></td>
</tr>
<tr>
<td></td>
</tr>
</table>
<!--Page body Section end here-->
</td>
</tr>
</table>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td>
</td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
";
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= 'From: xxxxx' . "\r\n";
mail($to, $subject, $message, $headers);
?>

----------------------------- end of code-----------------------
some variables are used to change language
and
$mail_contents is the vatiable of mail contents which is partly from database and partyt from use input.
Plz. solve my prob

    if this is oyur php code then for starters you need to echo out all html code

    for example echo"</tr>";

    if you have a form like <form action="submit"> you need to do this echo "<form action=\"submit\"> if you are using php 4 php 5 i believ you dnt

      His PHP syntax looks fine at a glance, he isn't echo'ing anything, he is setting his $message variable to a string of html text...

      OP, I've found it easier to NOT include any of the <html>, <body>, <head> and their closing tags in html emails... I simply send the html you'd put INSIDE the <body> tag but NOT including the <body> tag.

      hth,
      stolzyboy

        stolzyboy wrote:

        His PHP syntax looks fine at a glance, he isn't echo'ing anything, he is setting his $message variable to a string of html text...

        OP, I've found it easier to NOT include any of the <html>, <body>, <head> and their closing tags in html emails... I simply send the html you'd put INSIDE the <body> tag but NOT including the <body> tag.

        hth,
        stolzyboy

        i never said his syntax isnt correct i aint really looked into it completely

        i jsut said IF it is there php code any html code will need to be echoed out to work properly or else it cause problems since it not php code its one of the problems i had for a while with a mysql update script i was doing then i found out that all you have to do is make the html as a echo as then it fine

        Sorry i wasnt clear on what i said

          you do NOT need to echo HTML, you can simply close php and reopen it, furthermore, it's easier to read and i've done numerous time tests and it is faster, albeit marginally, but it IS faster 🙂

          <?php
          if (condition)
          {
          ?>
          <HTML_HERE>
          <?php
          }
          else
          {
          ?>
          <MORE_HTML_HERE>
          <?php
          }
          ?>
            stolzyboy wrote:

            you do NOT need to echo HTML, you can simply close php and reopen it, furthermore, it's easier to read and i've done numerous time tests and it is faster, albeit marginally, but it IS faster 🙂

            <?php
            if (condition)
            {
            ?>
            <HTML_HERE>
            <?php
            }
            else
            {
            ?>
            <MORE_HTML_HERE>
            <?php
            }
            ?>

            I agree that it is better that way

            But, the code provide suggests its all php with no opening and closign of php before html hence why i said ot echo it out but without the full code i cant say for sure

            There is time when it best ot include the html into the php esicpally if its a if,else scernio and it invoolves a form in the else part you dnt want he form appearing during the if but that a different type case

              I showed you an if/else with the html NOT in PHP, as long as the condition works, the else html will not show up regardless if it's in PHP tags or not, all the PHP tags tell the parser to do it parse it as PHP, if it's not in PHP, it'll just render it as plain html

                stolzyboy wrote:

                His PHP syntax looks fine at a glance, he isn't echo'ing anything, he is setting his $message variable to a string of html text...

                OP, I've found it easier to NOT include any of the <html>, <body>, <head> and their closing tags in html emails... I simply send the html you'd put INSIDE the <body> tag but NOT including the <body> tag.

                hth,
                stolzyboy

                hi
                this code is the part of page (sendmail.php)
                The page is working fine and I am geting also email in html format.
                But ong question is I am getting some garbege charcters istade of original character

                Plz. solve my problem!!!!1

                  can you put some "test" text in all over the email to see where the garbage starts and ends... or maybe you know that already

                    Already I have tested this
                    Whereever the language is english it display nice, but not in other language ( russian, german).

                    In my mail content where ever the variables like $mail4_invitationsent ,$mail5_invitationsent are in a separate language file which is included in mail page to provide various language.

                    But the variables from the language page is right and it display right language in web page.

                    All the contents are mail content is garbege ( entry of the user, value from database, and variables from language file )

                    The mail content is right with english language but garbage in other language.

                    I think I is the play of unicode??????????

                    Plz. help me.

                      Write a Reply...