Welcome Guest, Not a member yet? Register   Sign In
Email class 500 error (internal server error)
#1

[eluser]Thyvo[/eluser]
I'm messing around for like 2 days with a error I cant resolve,

Each time I wish to user this code (see below) I'm getting a 500 internal server error, no CI error or php error.

Please someone know what the problem is?

ps. commented code works but if I wish to use a loop it crashes

Code:
<?php
class Emails extends CI_Model {

    function __construct()
    {
        parent::__construct();
    }
    function urgent($date, $subject){
     $this->load->library('email');
  $inc = $this->db->query("SELECT * FROM `users` WHERE `mailing` = 1 ORDER BY  `users`.`name` ASC ");
  $emails = $inc->result();
  //$addresses = array('[email protected]','[email protected]');
  foreach($emails as $emailss){
   $message = "New urgent mail \n Subject: $subject";  
   $this->email->clear();
   $this->email->to($emailss->email);//yes the table is correct
   $this->email->from('[email protected]');
   $this->email->subject('Urgent email!');
   $this->email->message($message);
   $this->email->send()
  }
}
/*function urgent($date,$subject){
  

  $adres = "[email protected]";
  $this->load->library('email');
  $this->email->to($adres);
     $this->email->from('[email protected]');
     $this->email->subject('Here is your info ');
     $this->email->message('Hi, Here is the info you requested.');
     $this->email->send();
     echo $this->email->print_debugger();
}*/
}
?>

Please someone, I really need to get this up as soon as possible

Grtz Thyvo
#2

[eluser]rthut[/eluser]
Are you trying to send through your local mail server?
If so, why do not you try using the SMTP protocol?

Here is Google SMTP example
Code:
$config = Array(
    'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtp.googlemail.com',
    'smtp_port' => 465,
    'smtp_user' => '[email protected]',
    'smtp_pass' => 'your_password',
);
$this->load->library('email', $config);
#3

[eluser]CroNiX[/eluser]
User Guide: Database Results
A few things.

This returns an array of results.
Code:
$emails = $inc->result();

If you are only retrieving a single row, use
Code:
$inc->row();
and then what you have should work ok.

Or else you would need to access like $emailss[0]->email (or else iterate over the $emailss array).

Look at your retrieved data by doing a print_r($emails) right after you retrieve $emails to see what I mean.




Theme © iAndrew 2016 - Forum software by © MyBB