0

I've recently taken over a large project written in Codeigniter. I am working on my local machine and want to make sure that I don't accidentally send any emails out to real users.

Is there anyway I can override email recipients globally, so that any messages that do get sent out come to me instead of them?

Any advice appreciated.

Thanks

Dan
  • 6,265
  • 8
  • 40
  • 56
  • 1
    http://stackoverflow.com/questions/5773288/configure-wamp-server-to-send-email. You can install it locally. The emails wont go locally to any user if you are using wamp etc. Set it to some email address then open in outlook – Muhammad Raheel Jun 04 '14 at 09:41
  • 1
    If you use SMTP server, you can use [FakeSMTPserver](http://nilhcem.github.io/FakeSMTP/). I use it locally to deal with this kind of thanks – manix Jun 05 '14 at 05:03

1 Answers1

1

you can open system/libraries/Email.php file and find the method "to" approx line number is 260.

public function to($to)
    {
        $to = $this->_str_to_array($to);
        $to = $this->clean_email($to);

        if ($this->validate)
        {
            $this->validate_email($to);
        }

        if ($this->_get_protocol() != 'mail')
        {
            $this->_set_header('To', implode(", ", $to));
        }

        switch ($this->_get_protocol())
        {
            case 'smtp'     :
                $this->_recipients = $to;
            break;
            case 'sendmail' :
            case 'mail'     :
                $this->_recipients = implode(", ", $to);
            break;
        }

        return $this;
    }

this is the function which gets called to set the to address of the mail. you can manually override the "to" address with your mail address. for example:

$this->_recipients ="your_mail_address@host.com";
return $this;

at the end of the method. i dont know is the good method but you can kick start your tasks with local project copy.

Joe
  • 618
  • 1
  • 9
  • 18