• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tank Auth Email Problem

#1
[eluser]fillipe.bs[/eluser]
Hello Guys,

I'm starting with CodeIgniter. I read the UserGuide and I've used the search without sucess.

So, that is the problem, Tank Auth is installed in my CodeIgniter project, but when I try to register, the registration email is not sent.

I edited Email.php in system/libraries to this:

Code:
var    $useragent        = "CodeIgniter";
    var    $mailpath        = "/usr/sbin/sendmail";    // Sendmail path
    var    $protocol        = "smtp";    // mail/sendmail/smtp
    var    $smtp_host        = "ssl://smtp.gmail.com";        // SMTP Server.  Example: mail.earthlink.net
    var    $smtp_user        = "email@google.com";        // SMTP Username
    var    $smtp_pass        = "Password";        // SMTP Password
    var    $smtp_port        = "465";        // SMTP Port
    var    $smtp_timeout    = 7;        // SMTP Timeout in seconds
    var    $wordwrap        = TRUE;        // TRUE/FALSE  Turns word-wrap on/off
    var    $wrapchars        = "76";        // Number of characters to wrap at.
    var    $mailtype        = "text";    // text/html  Defines email formatting
    var    $charset        = "utf-8";    // Default char set: iso-8859-1 or us-ascii
    var    $multipart        = "mixed";    // "mixed" (in the body) or "related" (separate)
    var $alt_message    = '';        // Alternative message for HTML emails
    var    $validate        = FALSE;    // TRUE/FALSE.  Enables email validation
    var    $priority        = "3";        // Default priority (1 - 5)
    var    $newline        = "\r\n";        // Default newline. "\r\n" or "\n" (Use "\r\n" to comply with RFC 822)
    var $crlf            = "\r\n";        // The RFC 2045 compliant CRLF for quoted-printable is "\r\n".  Apparently some servers,
                                    // even on the receiving end think they need to muck with CRLFs, so using "\n", while
                                    // distasteful, is the only thing that seems to work for all environments.
    var $send_multipart    = TRUE;        // TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override.  Set to FALSE for Yahoo.
    var    $bcc_batch_mode    = FALSE;    // TRUE/FALSE  Turns on/off Bcc batch feature
    var    $bcc_batch_size    = 200;        // If bcc_batch_mode = TRUE, sets max number of Bccs in each batch
    var $_safe_mode        = FALSE;
    var    $_subject        = "";
    var    $_body            = "";
    var    $_finalbody        = "";
    var    $_alt_boundary    = "";
    var    $_atc_boundary    = "";
    var    $_header_str    = "";
    var    $_smtp_connect    = "";
    var    $_encoding        = "8bit";
    var $_IP            = FALSE;
    var    $_smtp_auth        = TRUE;
    var $_replyto_flag    = FALSE;

The file email.php in application/config is this:
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

/*
| -------------------------------------------------------------------------
| Email
| -------------------------------------------------------------------------
| This file lets you define parameters for sending emails.
| Please see the user guide for info:
|
|    http://ellislab.com/codeigniter/user-guide/libraries/email.html
|
*/
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['newline'] = '\r\n';


/* End of file email.php */
/* Location: ./application/config/email.php */

But if i try to send an simple email (with the same system/libraries/Email.php) like this:
Code:
//Testanto o Email
        $this->email->from('email@gmail.com', 'My name');
        $this->email->to('email@gmail.com');
        
        $this->email->subject('Email de Teste!');
        $this->email->message('Este é o corpo do meu email de Teste!');
        
        $this->email->send();
        
        echo $this->email->print_debugger();
That works...

Any idea of what is the problem?

#2
[eluser]fillipe.bs[/eluser]
Guys,

removing the email.php (config file) and setting the variables in Email class directly, all works, I dont know if there is an bug of CodeIgniter 2.0 or in Tank Auth, or if i'm a realy noob.

So, if you culd help me i'll be thankfull.

#3
[eluser]Unknown[/eluser]
I had the same problem and couldnt figure it out either. Finally i tried what fillipe.bs suggested and it helped resolve the problem. But make sure that for Tank Auth to work you set all the expected parameters in the email class. (system/libraries/email.php)
Code:
var    $useragent        = "CodeIgniter";
    var    $mailpath        = "/usr/sbin/sendmail";    // Sendmail path
    var    $protocol        = "smtp";    // mail/sendmail/smtp
    var    $smtp_host        = "ssl://smtp.googlemail.com";        // SMTP Server.  Example: mail.earthlink.net
    var    $smtp_user        = "xxxxx@xxxx";        // SMTP Username
    var    $smtp_pass        = "xxxxx";        // SMTP Password
    var    $smtp_port        = 465;        // SMTP Port
    var    $smtp_timeout    = 5;        // SMTP Timeout in seconds
    var    $wordwrap        = TRUE;        // TRUE/FALSE  Turns word-wrap on/off
    var    $wrapchars        = "76";        // Number of characters to wrap at.
    var    $mailtype        = "html";    // text/html  Defines email formatting
    var    $charset        = "utf-8";    // Default char set: iso-8859-1 or us-ascii
    var    $multipart        = "mixed";    // "mixed" (in the body) or "related" (separate)
    var $alt_message    = '';        // Alternative message for HTML emails
    var    $validate        = FALSE;    // TRUE/FALSE.  Enables email validation
    var    $priority        = "3";        // Default priority (1 - 5)
    var    $newline        = "\r\n";    // Default newline. "\r\n" or "\n" (Use "\r\n" to comply with RFC 822)
The protocol and smtp details are obvious but I had missed out on the \r\n for newline and this was causing the register page in tank auth to time out or not give any response even after a long long long time. So please be careful - the default is only \n which doesnt work with Tank Auth and gives no response. Also the mailtype should be html.

Once i got this working - i tested the test mail. Here is a simple test mail controller - and it works for the scenarios where you set everything in the Email.php (system/libraries/email.php) as follows
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Test_Mail extends CI_Controller {

    function __construct()
    {
        parent::__construct();
    }

    function index()
    {

        $this->load->library('email');
        $this->email->set_newline("\r\n");

        // Set to, from, message, etc.

        $this->email->from('xxx@localhost', 'Post Master');
        $this->email->to('xx@xxx);

        $this->email->subject('Email Test');
        $this->email->message('Testing the email class using no config here.');    

        $this->email->send();

        echo $this->email->print_debugger();
    }
}

/* End of file test_mail.php */
/* Location: ./application/controllers/test_mail.php */
Again note the $this->email->set_newline("\r\n"). This is essential i guess.

And also works fine without loading everything in the Email.php class and passing it as a configuration array.

Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Test_Mail extends CI_Controller {

    function __construct()
    {
        parent::__construct();
    }

    function index()
    {

        $config = Array(
           'protocol' => 'smtp',
             'smtp_host' => 'ssl://smtp.googlemail.com',
            'smtp_port' => 465,
            'smtp_user' => 'xxx@gxxx',
            'smtp_pass' => 'xxx',
            'mailtype'  => 'html',
            'charset'   => 'iso-8859-1'
        );


        $this->load->library('email');
        $this->email->initialize($config);

        $this->email->set_newline("\r\n");

        // Set to, from, message, etc.

        $this->email->from('xxx@localhost', 'Post Master');
        $this->email->to('xx@xxx.in');

        $this->email->subject('Email Test');
        $this->email->message('Testing the email class using no config here.');    

        $this->email->send();

        echo $this->email->print_debugger();
    }
}

/* End of file test_mail.php */
/* Location: ./application/controllers/test_mail.php */

Once again - $this->email->set_newline("\r\n") appears in the test and i do consider it important now.

Unfortunately one scenario that still needs investigation is setting the config in the email.php (applications/config/email.php) - which i have read else where isnt working - a problem with code igniter or tank auth - no idea, but after exhausting myself with my trail and errors all day - just didnt have the energy to test this and going to take a hint from other threads which says to delete the config/email.php.

However i am going to need to make this work with Mercury mail (XAMPP on Win7) on localhost
since my gmail ports are blocked at office - so will post those details here as well for anyone else like me trying out the same.

But i did restart apache after my changes - so think that might help too though not necessarily!


Reference threads:
http://ellislab.com/forums/viewthread/17485
http://ellislab.com/forums/viewthread/183864/
http://ellislab.com/forums/viewthread/132443/

#4
[eluser]Lechuss[/eluser]
Added $this->email->initialize(); to _send_email() fixed this for me.

#5
[eluser]Unknown[/eluser]
Hi, you can try in your config/email.php file:

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_port'] = 465;
$config['smtp_user'] = 'xxxx@xxx.xxx'; // your email
$config['smtp_pass'] = 'xxx'; // your password
$config['mailtype'] = 'html';
$config['charset'] = 'iso-8859-1';

I know this is an old thread, but maybe this help someone...


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.