this is my controller i am very new to codeigniter.
--------------------------------------------------------
public function joinus()
     {
         if($this->input->post('submit'))
    {
        $this->load->library('email');
        $to=$this->admin_model->get_goinmail();
        $from='';
        $subject='';
        $message='';

        $config['mailtype'] = 'html';
        $config['protocol'] = 'sendmail';

        $this->email->initialize($config);
        $this->email->set_newline("\r\n");
        $this->email->from($from);
        $this->email->to(@$to); 
        $this->email->subject(@$subject);
        $this->email->message(@$message);

        if($this->email->send())
            {
                $data['mail_status']="sucess";  
            }else{
                $data['mail_status']="Un sucess";
            }
            }
          $data['get_goinmail']=$this->admin_model->get_goinmail();
          $data['content'] = $this->load->view($this->view_dir .'joinus',$data,TRUE);   
          $this->load->view('template',$data);
    }


    i want to send mail to list of members.

    ---------------------------------------------------------------
    ---------------------------------------------------------------

    hear iam getting this error 

    Severity: Warning

Message: preg_match() expects parameter 2 to be string, array given

Filename: libraries/Email.php

Line Number: 795


A PHP Error was encountered

Severity: Notice

Message: Array to string conversion

Filename: libraries/Email.php

Line Number: 272
--------------------------------------
--------------------------------------


A PHP Error was encountered

Severity: Notice

Message: Array to string conversion

Filename: libraries/Email.php

Line Number: 272



A PHP Error was encountered

Severity: Notice

Message: Array to string conversion

Filename: libraries/Email.php

Line Number: 282
A PHP Error was encountered

Severity: Notice

Message: Array to string conversion

Filename: libraries/Email.php

Line Number: 282


thanks in advance...

Hi,

It seems you are sending a multidimensional array to this variable:

$to = $this->admin_model->get_goinmail();

You can submit arrays but in this form: $to = array('donald@email.tld','mickey@email.tld');
Also you are sending empty variables to these functions, so it will not work:

$this->email->from($from);
$this->email->subject(@$subject);
$this->email->message(@$message)

Important: remove the @ from the variables, otherwise you will not see errors, if you want to prevent errors from displaying you can edit index.php and change:

define('ENVIRONMENT', 'development');

to:

define('ENVIRONMENT', 'production');

Keep in mind that you can use the batch mode to loop the list and limit the amout of resources used by the script: http://ellislab.com/codeigniter/user-guide/libraries/email.html

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.