About the mail().

From: Date: Sat, 30 Apr 2005 03:08:23 +0000
Subject: About the mail().
Groups: php.general 
Request: Send a blank email to php-general+get-214257@lists.php.net to get a copy of this message
Hi lists: I am new here. And i know little about php. Sorry ask so stupid question. I want to use my local /usr/sbin/sendmail to send mail to a certain address. I have checked the function_list in http://www,php.net. And i found the mail(). It enough to my requirement. And i have written a php file like below: <?php if($_POST['send']) { $message = $_POST['message']; $body = "姓名:" . $message['username'] . "\n" . "邮件地址:" . $message['usermail'] . "\n" . "公司名称:" . $message['compname'] . "\n" . "电话号码:" . $message['telephone'] . "\n\n" . "问题主题:" . $message['subject'] . "\n" . "问题内容:" . $message['content'] . "\n"; $headers .= "Content-Transfer-Encoding: UTF-8\n"; $headers .= "Content-Type: text/plain; charset=utf-8\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "From: help@example.com\n"; $headers .= "X-Mailer: Online Help!(http://www.example.com)\n"; mail('wangpenghui@realss.com', '我需要帮助! ', $body, $headers); header("Location: http://www.example.com"); } if($_POST['cancel']) { header("Location: http://www.example.com"); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh" > <head> <title>在线提问</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head> <body> <h1 style="text-align:center;color: red">在线帮助</h1> <div style="margin: auto; width: 65%;"> <p>这里是在线帮助模块,如果您有任何问题或疑问,您可以将它填写在下面,这样我们就可以在第一时间得到您的问题,尽快给您以帮助.</p> <form method="post"> <fieldset> <legend>您的联系信息</legend> 您的姓名:<input type="text" name="message[username]" > 邮件地址:<input type="text" name="message[usermail]" ><br> 公司名称:<input type="text" name="message[compname]" > 电话号码:<input type="text" name="message[telephone]" > </fieldset> <fieldset> <legend>您想问的问题</legend> 主题:<input name="message[subject]" type="text" size="30" value="" maxLength="100"><br> 内容:<textarea name="message[content]"rows="10" cols="70"></textarea> <div style="text-align:center"> <input type="submit" name="send" value="发送"> <input type="submit" name="cancel" value="取消"> </div> </fieldset> </form> </div> </body> </html> But all the chinese words could change to "????". The charset of this file is UTF-8. I wonder know how to deal with it. And i am blind with it now. Because the lack of experience with php. Best regards Wang Penghui

« previous php.general (#214257) next »