dongqiao9015 2013-03-24 22:17
浏览 24
已采纳

我无法在CodeIgniter纯文本电子邮件中获得行返回

I've been struggling with this one. No matter what I do, I cannot get new lines, empty lines, or line returns to show up in any email message I generate with CodeIgniter (v 2.1.3).

Within my Controller function:

$message = "Line one.

" .
"Line two.

" .
"Line three.

";

$subject = "My Subject Line";

$this->load->library('email');                  
$config['newline'] = "
";  // does not matter when I leave this out
$config['crlf'] = "
";     // does not matter when I leave this out
$this->email->initialize($config);              
$this->email->from('system@mydomain.com', 'my system');
$this->email->to('me@gmail.com');               
$this->email->subject($subject);
$this->email->message($message);                
$this->email->send();               
echo $this->email->print_debugger();

I've changed no settings or defaults, other than what I've shown above.

The "source" of the message looks just like this print_debugger() output...

User-Agent: CodeIgniter
Date: Sun, 24 Mar 2013 17:46:47 -0400
From: "my system" 
Return-Path: 
Reply-To: "system@mydomain.com" 
X-Sender: system@mydomain.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <xxxxxx@mydomain.com>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_514f74472bd26" 

=?utf-8?Q?My_Subject_Line?=
This is a multi-part message in MIME format.
Your email application may not support this format.

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

Line one.

Line two.

Line three.

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

Line one.

Line two.

Line three.

--B_ALT_514f74472bd26--

HOWEVER, the problem is that the actual message is rendering in all email clients as the following.

Line one.Line two.Line three.

Why are my " " being ignored?

This is a very simple message and I'd prefer to not have to use any html options. As per CI documentation, the mailtype preference should be defaulting to text.

Where am I going wrong here?

  • 写回答

2条回答 默认 最新

  • dreamworld2007 2013-03-24 22:37
    关注

    The CodeIgniter 2 documentation appears to be wrong.

    On this page, it contains a listing of available preferences.

    Note this one, mailtype...

    Preference     Default Value      Options       
    mailtype       text               text or html 
    

    Adding the following setting fixed this problem, so clearly it's not the "default value"...

    $config['mailtype'] = 'text';
    

    My thread at CI asking about this discrepancy in the docs:

    http://ellislab.com/forums/viewthread/234296/


    EDIT:

    Entire problem was being caused by the following code within my Ion Auth configuration file...

    $config['email_config'] = array(
        'mailtype' => 'html',
    );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历