未加星标

How do I send emails with Arabic html content to php smtp

字体大小 | |
[开发(php) 所属分类 开发(php) | 发布者 店小二04 | 时间 2018 | 作者 红领巾 ] 0人收藏点击收藏

Want to send arabic html content on mail

I Tried require_once "Mail.php"; require_once "Mail/mime.php"; // see http://pear.php.net/manual/en/package.mail.mail-mime.php // for further extended documentation on Mail_Mime mb_internal_encoding("UTF-8"); $from = "<a href="/cdn-cgi/l/email-protection" data-cfemail="0b7f6e787f4b6d79646625686466">[email protected]</a>"; $to = "<a href="/cdn-cgi/l/email-protection" data-cfemail="493d2c3a3d092f3b2624672a2624">[email protected]</a>" $subject = "Test HTML email usingphp Pear w/ SMTP\r\n\r\n"; $text = "This is a text test email message"; $html = "<meta charset='utf-8' /><html><body> ! " " . </body></html>"; $crlf = "\n"; // create a new Mail_Mime for use $mime = new Mail_mime($crlf); // define body for Text only receipt $mime->setTXTBody($text); // define body for HTML capable recipients $mime->setHTMLBody($html); // specify a file to attach below, relative to the script's location // if not using an attachment, comment these lines out // set appropriate MIME type for attachment you are using below, if applicable // for reference see http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types $file = "attachment.jpg"; $mimetype = "image/jpeg"; $mime->addAttachment($file, $mimetype); // specify the SMTP server credentials to be used for delivery // if using a third party mail service, be sure to use their hostname $host = "*******"; $username = "************"; $password = "*******"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject, 'Content-Type' => 'text/html; charset=UTF-8'); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $body = $mime->get(); $headers = $mime->headers($headers); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { //echo(" " . $mail->getMessage() . " "); echo 1; } else { //echo(" Message successfully sent! "); echo 2; } ?>

but in mail getting data like:

± ¨ §§ ¨ ± ¨§ §¨ ‰ …§ § ‰ … "§§… §§" …!

so waht to do here?

Please help me

you can use PHPMailer Class

it is powerful , and open source . for get examples please read this PHPMailer class examples

example for arabic , persian and etc.

<?php require_once('class.phpmailer.php'); $mail = new PHPMailer(true); $mail->IsSMTP(); try { $mail->Host = "smtp.gmail.com"; $mail->SMTPAuth = true; $mail->SMTPSecure = "tls"; $mail->Port = 587; $mail->Username = "<a href="/cdn-cgi/l/email-protection" data-cfemail="542d3b21263a353931143339353d387a373b39">[email protected]</a>"; $mail->Password = "************"; $mail->AddReplyTo('<a href="/cdn-cgi/l/email-protection" data-cfemail="3841574d4a5659555d785d40595548545d165b5755">[email protected]</a>', 'Your Name'); $mail->AddAddress('<a href="/cdn-cgi/l/email-protection" data-cfemail="cbbeb8aeb9a5aaa6ae8baeb3aaa6bba7aee5a8a4a6">[email protected]</a>', 'User Name'); $mail->SetFrom('<a href="/cdn-cgi/l/email-protection" data-cfemail="8af3e5fff8e4ebe7efcaeff2ebe7fae6efa4e9e5e7">[email protected]</a>', 'Your Name'); // $mail->Subject = ''; $mail->AltBody = ' '; // $mail->CharSet = 'UTF-8'; $mail->ContentType = 'text/html'; $mail->MsgHTML('<html> <body> <font color="#CC0000"></font> ! </body> </html>'); // html //$mail->AddAttachment('images/phpmailer.gif'); // $mail->Send(); echo " \n"; } catch (phpmailerException $e) { echo $e->errorMessage(); } catch (Exception $e) { echo $e->getMessage(); } ?>

本文开发(php)相关术语:php代码审计工具 php开发工程师 移动开发者大会 移动互联网开发 web开发工程师 软件开发流程 软件开发工程师

tags: gt,mail,lt,email,html,mime,body,echo,data,protected,cgi,cdn,href
分页:12
转载请注明
本文标题:How do I send emails with Arabic html content to php smtp
本站链接:https://www.codesec.net/view/604920.html


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 开发(php) | 评论(0) | 阅读(14)