Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/250.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用CodeIgniter的电子邮件编码不正确_Php_Codeigniter_Email_Encoding_Codeigniter 2 - Fatal编程技术网

Php 使用CodeIgniter的电子邮件编码不正确

Php 使用CodeIgniter的电子邮件编码不正确,php,codeigniter,email,encoding,codeigniter-2,Php,Codeigniter,Email,Encoding,Codeigniter 2,现在,数据库中的数据如下所示: Hej[indtaster_navn]我为您的手术准备了一份xxxxxx的医疗文件:-xxxx-xxxx-xxxx杰格维尔·格尔内已经完成了手术,手术室位于奥文德。[behandler\u email]这是一些东西Transformer 12343434 BubbleJ​​​​ 因此,在发送邮件时,我有以下代码,需要注意的是,我使用了html\u entity\u decode: $config['mailtype'] = 'html'; $con

现在,数据库中的数据如下所示:

Hej[indtaster_navn]



我为您的手术准备了一份xxxxxx的医疗文件:

-xxxx
-xxxx
-xxxx

杰格维尔·格尔内已经完成了手术,手术室位于奥文德。

[behandler\u email]

这是一些
东西
Transformer 1234
3434 BubbleJ

​​​​

因此,在发送邮件时,我有以下代码,需要注意的是,我使用了
html\u entity\u decode

    $config['mailtype'] = 'html';
    $config['priority'] = 1;
    $config['charset'] = 'utf-8';
    $this->email->initialize($config);
    $this->email->from($this->auth_data->user_email, $this->auth_data->user_firstname . ' ' . $this->auth_data->user_lastname);
    $this->email->reply_to($this->auth_data->user_email, $this->auth_data->user_firstname . ' ' . $this->auth_data->user_lastname);
    $this->email->to('test@test.com'); 
    $this->email->subject($feedback_title_temp);
    $this->email->message(html_entity_decode($feedback_temp));  
    $this->email->send();
当我收到电子邮件时,它会在随机位置插入符号
=
,在某些情况下,

甚至不会出现

例如:

- xxxx<=r>- xxxx
当我在智能手机上查看电子邮件时,编码问题似乎只出现在
æåø
字符上,而Outlook则完全不同

收到的电子邮件标题::

**Microsoft Mail Internet Headers Version 2.0
Subject: =?utf-8?Q?(ID:_418)?=
To: some@one.com
X-PHP-Originating-Script: 0:Email.php
User-Agent: CodeIgniter
Date: Wed, 7 Nov 2012 00:31:54 +0100
From: <mat@damn.com>
Return-Path: <mat@damn.com>
Reply-To: "Johnny Bravo" <mat@damn.com>
X-Sender: damn@test.com
X-Mailer: CodeIgniter
X-Priority: 1 (Highest)
Message-ID: <50999deab797d@test.com>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_50999deab798e"
X-OriginalArrivalTime: 06 Nov 2012 23:31:54.0823 (UTC) FILETIME=[E8022570:01CDBC76]

--B_ALT_50999deab798e
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

--B_ALT_50999deab798e
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable


--B_ALT_50999deab798e--
**
**Microsoft Mail Internet邮件头版本2.0
主题:=?utf-8?Q?(ID:_418)=
致:some@one.com
X-PHP-origing-Script:0:Email.PHP
用户代理:CodeIgniter
日期:2012年11月7日星期三00:31:54+0100
发件人:
返回路径:
答复:“约翰尼·布拉沃”
X-Sender:damn@test.com
X-Mailer:CodeIgniter
X优先级:1(最高)
消息ID:
Mime版本:1.0
内容类型:多部分/可选;边界=“B_ALT_50999; deab798e”
X-OriginalArrivalTime:2012年11月6日23:31:54.0823(UTC)文件时间=[E8022570:01CDBC76]
--B_ALT_50999; DEAB798E
内容类型:文本/普通;字符集=utf-8
内容传输编码:8比特
--B_ALT_50999; DEAB798E
内容类型:text/html;字符集=utf-8
内容传输编码:引用可打印
--B_ALT_50999; DEAB798E--
**
收到的邮件,基于不同的内容,但错误非常明显:

Det her er en m=sse tekst, det er bare en test fra en hæææst.


- Hehe
- Heh<=br>
- Wee


A=l these things

- Lots of text
Det her en m=sse tekst,Det er bare en test fra en hæst。
-呵呵
-呵呵
-小便
这些东西
-大量文本

修复了这个问题!

你的数据库是什么编码?根据我的经验,脚本文件编码也会影响这一点。我的数据库的编码是
utf8\u general\u ci
。php文件是否也保存为utf-8?为什么在将其放入数据库之前对html实体进行编码?@JavaCake:ci默认情况下不会这样做。这与我们无关安全性。我问你是因为在存储到数据库之前对其进行编码并在检索后进行解码是没有意义的。你在这个过程中添加的逻辑越多,你需要调试的东西就越多,以找到问题的根源。这是一个救世主!
Det her er en m=sse tekst, det er bare en test fra en hæææst.


- Hehe
- Heh<=br>
- Wee


A=l these things

- Lots of text
$this->email->set_crlf( "\r\n" );