简体   繁体   English

使用PHP Pear :: Mail多语言(泰米尔语)邮件发送,修剪收件箱邮件中的正文内容

[英]Using PHP Pear::Mail multilingual (Tamil) mail sending, trimmed the body content in my inbox mail

I am implementing multilingual support to one of my application. 我正在为我的一个应用程序实现多语言支持。 In that I am trying to send multilingual mail using PHP Pear::Mail & Pear::Mail_Mime packages. 我试图使用PHP Pear :: Mail&Pear :: Mail_Mime包发送多语言邮件。

Below is my mail sending functionality. 以下是我的邮件发送功能。

function _send($to, $subject, $content){

    $smtp_details = $this->settings->getSMTPDetails();

    $host         = $smtp_details['smtp_host'];
    $port         = $smtp_details['smtp_port'];
    $username     = $smtp_details['smtp_username'];
    $password     = $smtp_details['smtp_password'];
    $from_address = $smtp_details['smtp_email'];

    /*
     * Decode the Unicode string and encrypt the string
     */

    $subject    = base64_encode($subject);
    $content    = base64_encode($content);

    if ($this->settings->getLanguage() != LANGUAGE_ENGLISH){
        $subject    = '=?UTF-8?B?'.$subject.'?=';
    }

    $headers = array ('From' => $from_address,
              'To' => $to,
              'Subject' => $subject,
              'Content-Type' => 'text/html; multipart/related; boundary=DeS-mixed-{$_boundary}; charset=UTF-8\n',
              'Content-Transfer-Encoding' => 'BASE64',  
              'MIME-Version' => '1.0'  );

    // Creating the Mime message
    $mime = new Mail_mime("\n");

    // Setting the body of the email
    $mime->setHTMLBody($content);

    $body = $mime->get();

    //$header = $mime->headers($headers);

    $smtp = Mail::factory('smtp',array ('host' => $host,
                            'port' => $port,
                            'auth' => true,
                            'username' => $username,
                            'password' => $password));
    $connectionCount = 0;
    do {
        $mail = $smtp->send($to, $headers, $body);
        $connectionCount++;
        if (PEAR::isError($mail) && $connectionCount < 3) {
            //echo 'Retrying to send email using Host:'.$host;
             sleep(1);
        } else {
            if (PEAR::isError($mail)){
                throw new Exception('Mail sending error: '.$mail->getMessage());    
            }else{
                return true;
            }
        }

    }while (1);
   }

and the calling function is: 并且调用函数是:

echo $this->_send($to, json_decode("\u0B9A\u0BC7\u0BBE\u0BA4\u0BA9\u0BC8 \u0BAE\u0BBF\u0BA9\u0BCD\u0BA9\u0B9E\u0BCD\u0B9A\u0BB2\u0BCD"), json_decode("\u0B87\u0BA4\u0BC1 \u0B92\u0BB0\u0BC1 \u0B9A\u0BC7\u0BBE\u0BA4\u0BA9\u0BC8 \u0BAE\u0BBF\u0BA9\u0BCD\u0BA9\u0B9E\u0BCD\u0B9A\u0BB2\u0BCD"));

Note: The Email content is Unicode JavaScript Escape string. 注意:电子邮件内容是Unicode JavaScript Escape字符串。

Expected output: 预期产量:

Subject: சோதனை மின்னஞ்சல் 
Body: இது ஒரு சோதனை மின்னஞ்சல்

Actual output I am getting: 我得到的实际输出:

Subject: சோதனை மின்னஞ்சல் 
Body: இந்த ஒரு சோதனை மின்�®

Its getting trimmed into certain limit of email body content in my inbox. 它被修剪到我的收件箱中的电子邮件正文内容的某些限制。 Whether I missed any header configurations? 我是否错过任何标头配置? Anyone faces the same issue please share your solutions. 任何人都面临同样的问题请分享您的解决方案

Thanks in advance. 提前致谢。

Are you getting data from database? 您是从数据库获取数据吗? you need to send utf-8 encoding for email and database you this one before select any data 在选择任何数据之前,您需要为此电子邮件和数据库发送utf-8编码

mysql_query ("set character_set_client='utf8'"); mysql_query(“set character_set_client ='utf8'”); mysql_query ("set character_set_results='utf8'"); mysql_query(“set character_set_results ='utf8'”);

mysql_query ("set collation_connection='utf8_general_ci'"); mysql_query(“set collat​​ion_connection ='utf8_general_ci'”);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM