当字符使用波斯语时,我在将电子邮件从PHP发送到雅虎电子邮件时遇到问题。 代码是:
UITapGestureRecognizer(numberoftapsrequired = 1)
我没有问题发送到Gmail的文本内容,但在Yahoo邮件中,编码波斯语字符不起作用,它是这样的:
تناسٓبرنÙ......تاربÙ...نت
答案 0 :(得分:0)
你应该使用Mail Mime
这是来自git https://github.com/pear/Mail_Mime/blob/master/scripts/phail.php
中的Mail Mime存储库的示例<?php
/**
* PHAIL - stands for PHP Mail
* @author Tomas V.V.Cox <cox@idecnet.com>
*/
require_once 'Mail.php';
require_once 'Mail/mime.php';
require_once 'Console/Getopt.php';
$argv = Console_Getopt::readPHPArgv();
$opts = Console_Getopt::getOpt($argv, 'f:c:s:t:a:b:');
if (PEAR::isError($opts)) {
usage($opts->getMessage());
}
PEAR::setErrorHandling(PEAR_ERROR_DIE);
$mime = new Mail_mime;
foreach ($opts[0] as $opt) {
$param = $opt[2];
switch ($opt[0]) {
case 'f':
$headers['From'] = $param; break;
case 'c':
$headers['Cc'] = $param; break;
case 's':
$headers['Subject'] = $param; break;
case 't':
$to = $param; break;
case 'a':
$mime->addAttachment($param); break;
case 'b':
$isfile = @is_file($param) ? true : false;
$mime->setTXTBody($param, $isfile); break;
}
}
$mbody = $mime->get();
$headers = $mime->headers($headers);
$mail = Mail::factory('mail');
$mail->send($to, $headers, $mbody);
function usage($error)
{
die($error);
}
?>