Welcome Guest, Not a member yet? Register   Sign In
taking forever to send email using Codeigniter email library
#1

[eluser]MikeW1911[/eluser]
Hello, please keep in mind I am a beginner to Codeigniter and that I am using version 2.1.0, thank you.

I am trying to send an email using this controller code:

Code:
class Email extends CI_Controller {



public function index(){
  $config = Array(
   'protocol' => 'smtp',
   'smtp_host' => 'ssl://smtp.googlemail.com',
   'smtp_port' => 465,
   'smtp_user' => 'my gmail email address',
   'smtp_pass' => 'my gmail password',
   'mailtype'  => 'html',
      'charset'   => 'iso-8859-1'
  );
  $this->load->library('email', $config);
  
  $this->email->set_newline('\r\n');
  
  $this->email->from('my gmail email address', 'some guy');
  $this->email->to('my hotmail email address');
  $this->email->subject('this is an email test');
  $this->email->message('it is working. Great!');
  
  if ($this->email->send()){
   echo 'Your email was sent, fool.';
  }
  else{
   show_error($this->email->print_debugger());
  }
}
}

When I load the controller, the page does not finishing loading for some reason; I see neither "Your email was sent, fool." nor a debug report on the page. Tell me I didn't make a dumb mistake.
#2

[eluser]Stefan Hueg[/eluser]
This must be a timeout. Try this as your smtp-host:

Code:
'smtp_host' => 'smtp.googlemail.com',

'ssl://smtp.googlemail.com' is not resolvable.

If your timeout is taking 30 seconds, then you have reached the default maximum execution time.

In order to see the error messages, check that in CodeIgniter's index.php the ENVIRONMENT variable is set to "development" and that notices and warnings are not suppressed in your php.ini.
#3

[eluser]MikeW1911[/eluser]
NVM, I got it working!

this line:

Code:
$this->email->set_newline('\r\n');

should be this:

Code:
$this->email->set_newline("\r\n");
#4

[eluser]InsiteFX[/eluser]
When passing html tags like that you always need to use double quotes.
Code:
"\n \r \t etc."

Because of the \




Theme © iAndrew 2016 - Forum software by © MyBB