Welcome Guest, Not a member yet? Register   Sign In
Invalid argument supplied for foreach() in Email.php
#11

[eluser]CroNiX[/eluser]
[quote author="zoreli" date="1342004758"]Hi

Sorry about the delay of responding on the main question here, the value of $config variable.

using the print_r, the variable of the $config returns the following:

Reply-To: my_valiehere.... Return-Path: my_value_here... From: my_value_herel...

Hope this helps[/quote]
That's all wrong as none of that goes in the config. As others have mentioned, you should read the userguide for the email class. None of the valid options they show that can go in the config are in your config.

You should post all of your code dealing with sending your email if you want more help.
#12

[eluser]zoreli[/eluser]
Hi

Here is the code that send the mail.

Code:
function send_confirmation($user_id)
{
  $user_query = $this->db->query("SELECT user_email,user_confirmation_key FROM users WHERE user_id=?",array($user_id));
  $user_email = $user_query->row("user_email");
  $user_confirmation_key = $user_query->row("user_confirmation_key");


  /* Mail information */
  $mail_message = "" . SITE_NAME . ". \r\n\r\n Email message come here";

   //$mail_headers = $this->_get_mail_headers();
      //mail($user_email, SITE_NAME . " Registration", $mail_message, $mail_headers);
  $this->load->library('email');

  $this->email->from('[email protected]', 'Somethning');
  $this->email->to($user_email);

  $this->email->subject('Confirmation: SiteName. account');
  $this->email->message($mail_message);

  $this->email->send();
}

private function _get_mail_headers()
{
  $header = "Reply-To: " . SITE_NAME . " <" . REGISTRATION_EMAIL . ">\r\n";
  $header .= "Return-Path: " . SITE_NAME . " <" . REGISTRATION_EMAIL . ">\r\n";
  $header .= "From: " . SITE_NAME . " <" . REGISTRATION_EMAIL . "\r\n";
  $header .= "Organization: " . SITE_NAME . " \r\n";
  $header .= "Content-Type: text/plain\r\n";

  return $header;
}

I must mention again...e-mail has been sent...code works. I just want to get rid of the error message.



Regards zoreli
#13

[eluser]Aken[/eluser]
Do you have a /application/config/email.php file defined? That's the only other thing that could cause this error if you aren't supplying any configurations to the class.
#14

[eluser]zoreli[/eluser]
[quote author="Aken" date="1342219337"]Do you have a /application/config/email.php file defined? That's the only other thing that could cause this error if you aren't supplying any configurations to the class.[/quote]

I didn't have the email.php in my config folder. What that file is sopouse to have inside?

Code:
&lt;?php


$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;

Adding this code, sure enough did not prevent the error message.

Regards,Zoreli
#15

[eluser]Aken[/eluser]
Are you loading the Email library anywhere else - in the controller constructor or autoload? The library itself will not throw this error on its own - you have to be passing something invalid for it somewhere, or you have something corrupted, or some third-party code is causing it...

Try creating a new controller and load the Email library and see what happens. If it works, then you can narrow down your code a bit.
#16

[eluser]InsiteFX[/eluser]
1) Are you sure that the $user_id is valid?

2) How do you know that you are getting the correct data from the database when you are not checking anything for errors?

Try using var_dump and echo to make sure you are getting the right parameters for the email.




Theme © iAndrew 2016 - Forum software by © MyBB