当我尝试用Codeigniter发送电子邮件时,电子邮件不会用换行符发送。我试过一些写得断断续续的技巧,但没有奏效。
这是我的代码:
$message = 'Hi everyone'r'n';
$message .= 'Today you can look at these sites'r'n';
$message .= 'Have a good days';
$config['charset'] = 'utf-8';
$config['mailtype'] = 'text';
$config['newline'] = ''r'n';
$this->load->library('email');
$this->email->initialize($config);
$this->email->from('xxxxx@xxx.com');
$this->email->to('aaaa@aaaaaa.com');
$this->email->subject('Today New Sites');
$this->email->message($message);
$this->email->send();
我也试过了:
1.instead of putting 'r'n, I put only 'n and changed $config['newline'] = ''n'
2.I tried $this->email->message(nl2br($message));
3.I tried : str_replace(''r'n','"'r'n",$message);
4.I get rid of $config['mailtype']
请帮忙吗?
使用双引号"
而不是单引号'
。通过这种方式,换行符'n
将起作用。
更改$config['mailtype'] = 'html';
并使用<br/>
。