Welcome Guest, Not a member yet? Register   Sign In
Email Library woes
#1

[eluser]stuffradio[/eluser]
I'm using my own library to send email.

Code:
<?php

class Sendemaillib
{

  var $toUser;
  var $fromUser;
  var $theSubject;
  var $theMessage;

  function Sendemaillib()
  {
    $this->CI =& get_instance();
    $this->CI->load->library('email');
  }

  function sendIt()
  {
    if (isset($this->toUser) && isset($this->fromUser) && isset($this->theSubject) && isset($this->theMessage))
    {
      $this->CI->from($this->fromUser, 'Dean F');
      $this->CI->reply_to($this->fromUser, 'Dean F');
      $this->CI->to('[email protected]');
      $this->CI->subject($this->theSubject);
      $this->CI->message($this->theMessage);
      $this->CI->send();
    } else {
      $errors = array('error' => 'Not everything is set!');
      return $errors;
    }

    }

}

Whenever I try using this library, I get a blank page and Apache throws the following error:
Quote:PHP Fatal error: Call to undefined method Picture::from() in /var/www/vhosts/xxxxx/httpdocs/system/application/libraries/sendemaillib.php on line 21, referer: xxxxx/index.php/picture/id/2

Line 21 is
Quote: $this->CI->from($this->fromUser, 'Dean F');

The code using this is:

Code:
$this->sendemaillib->toUser = $getUser->email;
    $this->sendemaillib->fromUser = '[email protected]';
    $this->sendemaillib->theSubject = 'You got a new comment on an image!';
    $this->sendemaillib->theMessage = 'This is a test message!';
    $this->sendemaillib->sendIt();

Hope you can help!!!
#2

[eluser]mironcho[/eluser]
It seems that you have missed something - should be $this->CI->email->... instead of $this->CI->... in your sendIt() method.
#3

[eluser]stuffradio[/eluser]
I forgot to post that I tried it that way before as well... I was just trying different ways to see if it would work, but it doesn't.

So $this->CI->email doesn't work for me either.
#4

[eluser]louis w[/eluser]
Did you change them all to $this->CI->email ?

Code:
$this->CI->email->from($this->fromUser, 'Dean F');
      $this->CI->email->reply_to($this->fromUser, 'Dean F');
      $this->CI->email->to('[email protected]');
      $this->CI->email->subject($this->theSubject);
      $this->CI->email->message($this->theMessage);
      $this->CI->email->send();
#5

[eluser]stuffradio[/eluser]
Yeah, I already said I did :p
#6

[eluser]stuffradio[/eluser]
I solved my problem by using the native mail function. I'm not using this email library anymore because it screws up!




Theme © iAndrew 2016 - Forum software by © MyBB