0

I'm using WAMP Server on windows 7 and trying to configure Tank Auth with code Igniter.

While registration, Screen stuck on browser. I checked database that user was successfully inserted. With some debug, I was able to find that code is getting stuck while sending mail in _send_email function on Tank Auth's controller. Below is the code with debug statements.

function _send_email($type, $email, &$data)
{
    echo "In _send_email";

    $this->load->library('email');
    $this->email->from($this->config->item('webmaster_email', 'tank_auth'), $this->config->item('website_name', 'tank_auth'));
    $this->email->reply_to($this->config->item('webmaster_email', 'tank_auth'), $this->config->item('website_name', 'tank_auth'));
    $this->email->to($email);
    $this->email->subject(sprintf($this->lang->line('auth_subject_'.$type), $this->config->item('website_name', 'tank_auth')));
    $this->email->message($this->load->view('email/'.$type.'-html', $data, TRUE));
    $this->email->set_alt_message($this->load->view('email/'.$type.'-txt', $data, TRUE));

    echo "Before Sending";//exit;

    $this->email->send();

    echo "Mail Sent";
    echo $this->email->print_debugger();exit;
}

When I put exit before $this->email->send();, code worked fine but stuck as soon as I remove that exit. Clear indication that send() method is having problems.

I wrote another cotroller to test email as follow

public function view($slug){

    $this->load->library('email');
    $this->email->from('Myemail1', 'Kapil Sharma');
    $this->email->to('myemail2');
    $this->email->set_newline("\r\n");
    $this->email->subject('Email Test');
    $this->email->message('Testing the email class.<br>New Line.<br><strong>Strong</strong>');
    $this->email->send();

    $data['title'] = $data['news']['title'];

    $this->load->view('templates/header', $data);
    $this->load->view('news/view.html', $data);
    $this->load->view('templates/footer');
}

Which sent the mail successfully. Here is my email.php config, if needed

$config = Array(
    'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtp.googlemail.com',
    'smtp_port' => 465,
    'smtp_user' => 'myemail@gmail.com', //This is correct
    'smtp_pass' => 'mypassword',  //This is correct
    'mailtype' => 'html'
);

Can someone please identify what is the issue. Why sending email is not working in Tank Auth's Controller but working fine in another test controller. I cross checked both tank auth config file and english under lang is available.

Update

I updated subject line in _send_email as follow

//$this->email->subject(sprintf($this->lang->line('auth_subject_'.$type),$this->config->item('website_name', 'tank_auth')));
$this->email->subject('Test sub');

and code is working now. It seems there is some problem with lang. Checking if I can figure out the issue. Can someone quickly suggest why there is issue in $this->lang->line method.

Kapil Sharma
  • 10,135
  • 8
  • 37
  • 66
  • Just for info: I didn't set 'English' explicitly as language any where hoping CI will do it automatically as default language. Do I need to set that? – Kapil Sharma Jun 10 '13 at 07:27
  • What does this line output? $this->email->subject(sprintf($this->lang->line('auth_subject_'.$type), $this->config->item('website_name', 'tank_auth'))); – shin Jun 10 '13 at 08:20
  • Thanks for reply @shin. Sorry for late work. Went out for lunch. There is no output. It is using lang lib and I checked Tank auth didn't included lang library in its constructor and also not mentioned to import it in documentation. Reading documentation of lang lib of CI. I'll test again by manually including lang library & will report back soon. – Kapil Sharma Jun 10 '13 at 09:03
  • I think you need to clean up $this->email->subject() and $this->email->message(). – shin Jun 10 '13 at 09:14
  • @shin Yes even I know there is issue with `$this->email->subject()` but its third party code, recommended most on CI community for authentication and working for others. Thus I ideally don't want to edit that code but to fix its prerequisite, which I guess failing right now. As of now, I hope I need to load lang lib to make it work. Will report back with latest status once I do that. Right now reading lang lib docs. – Kapil Sharma Jun 10 '13 at 09:20
  • Solved. `$this->lang->line` was returning some special characters. Based on some other search, I saved lang file again with utf-8 encoding and it started working. – Kapil Sharma Jun 10 '13 at 10:13
  • Glad you solved it. Well done. – shin Jun 10 '13 at 10:31

0 Answers0