开发者

Codeigniter email problems

I am trying to send an email using codeigniters email library, this is my code,

$this->load->library('email');
$this->email->initialize(array('mailtype' => 'html'));
$this->email->from('emailaddresshidden'); // T开发者_如何学运维ODO - Store this in Config file??
$this->email->bcc('emailaddresshidden');
$this->email->subject('Competition Entry'); // TODO - What does this want to be??
$this->email->message($this->load->view('emails/competition_entry', $this->data, TRUE));
$this->email->send();

However I am getting this error,

A PHP Error was encountered

Severity: Warning

Message: mail() expects parameter 1 to be string, array given

Filename: libraries/Email.php

Line Number: 1519

I have no idea as to why?


According to https://bitbucket.org/ellislab/codeigniter/src/c9f9ca0fdb0c/system/libraries/Email.php#cl-257 it is important to use the method to() as @Pekka said. Else the the first parameter will not be transformed into a string.


you need to mention $this->email->to('receiver@email.com'); Then this error is resolved.


According to http://ellislab.com/forums/viewthread/201596/ all you gotta do is add a call to $this->email->to('') with a blank string as the first parameter.

$this->email->to("");
$this->email->bcc($emails);

This worked perfectly for me.


$this->email->to(' '); Just insert this line above the bcc() line.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜