CodeIgniter Forums
PHP mail() works but $this->email->send() does not - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: PHP mail() works but $this->email->send() does not (/showthread.php?tid=39936)

Pages: 1 2


PHP mail() works but $this->email->send() does not - El Forum - 03-24-2011

[eluser]Unknown[/eluser]
PHP 5.3.5, CI 2.0.1, Win2k8r2, IIS7.5 (not my choice for the OS or http server)

My PHP is a bit rusty so excuse me if I'm doing something stupid. CI is fairly new to me.

Sending mail using the PHP mail() function works fine. But when I try it using the email class I get a timeout message:

Quote:Fatal error: Maximum execution time of 300 seconds exceeded in C:\inetpub\wwwroot\ci\system\libraries\Email.php on line 1839

PHP timeout at
Code:
while ($str = fgets($this->_smtp_connect, 512))

My config/email.php

Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'mysmtp.com';
$config['smtp_port'] = '25';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;

No connection problems to my smtp server. Tested it with telnet and php mail().

Here's my test code:

Code:
<?php  class testmail extends CI_Controller {
     function index() {
          $this->load->library('email');
          $this->email->from('[email protected]');
          $this->email->to('<[email protected]>');
          $this->email->subject('Email Test');
          $this->email->message('Testing the email class.');
          $this->email->send();
          echo $this->email->print_debugger();
     }
}



PHP mail() works but $this->email->send() does not - El Forum - 03-25-2011

[eluser]kcmerrill[/eluser]
Given it's a timeout issue, my first guess is the the smtp host/port. Just for giggles, try telnet'ing to port 25 and see if you get a timeout issue there.

-kc


PHP mail() works but $this->email->send() does not - El Forum - 03-25-2011

[eluser]Unknown[/eluser]
Yep, that's what I thought at first. I tested the smtp server with telnet (port 25) and by sending php mail() to it. I also tested it against another smtp server. The smtp servers are not the problem. Otherwise why would PH mail() work? They are both configure to use the same server. Is Windows at the root of this?


PHP mail() works but $this->email->send() does not - El Forum - 03-25-2011

[eluser]InsiteFX[/eluser]
I may be wrong here but I think IIS uses IMAP for mail!

InsiteFX


PHP mail() works but $this->email->send() does not - El Forum - 04-04-2011

[eluser]dangermark[/eluser]
Anyone work this one out? I am having the exact same problem. Can telnet with no problems, but timing out when i attempt to email via my application.

config/email.php

Code:
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'mail.server.com';
$config['smtp_port'] = '25';
$config['charset'] = 'UTF-8';
$config['wordwrap'] = TRUE;

I am actually also on IIS 7 - Windows 2008 Server.


PHP mail() works but $this->email->send() does not - El Forum - 04-04-2011

[eluser]MVUG[/eluser]
Isn't there a bug in the mail class of CI? I thought I red somewhere that the php mail() function that CI utilizes is not correct...


PHP mail() works but $this->email->send() does not - El Forum - 04-04-2011

[eluser]InsiteFX[/eluser]
Look at your mail settings in php.ini !

InsiteFX


PHP mail() works but $this->email->send() does not - El Forum - 04-04-2011

[eluser]Glazz[/eluser]
@MVUG - Nope, i use the ci email library and it works great.


@tired_admin - Are you passing the username and the password for that smtp account?


PHP mail() works but $this->email->send() does not - El Forum - 04-04-2011

[eluser]InsiteFX[/eluser]
Code:
$config['smtp_timeout']    = 5;                // SMTP Timeout (in seconds). ( None )

// test your emails
// Returns a string containing any server messages, the email headers,
// and the email messsage. Useful for debugging.
echo $this->email->print_debugger();


InsiteFX


PHP mail() works but $this->email->send() does not - El Forum - 04-04-2011

[eluser]dangermark[/eluser]
I have other php applications running on the same server that do not have any problems with sending smtp mail. The mail server is configured to accept incoming smtp connections from certain IP addresses only and does not require user credentials. For testing purposes I have created a basic send mail page.

My controller:

Code:
class Sendemail extends CI_Controller {

  function __construct()
  {
    parent::__construct();
    $this->load->library('email');
    $this->config->load('email');
  }

  function index() {

    $this->email->from('[email protected]', 'Email Tester');
    $this->email->to('[email protected]');
    
    $this->email->subject('Email Test');
    $this->email->message('Testing the email. ');
    
    $this->email->send();
    
    echo $this->email->print_debugger();
  }
}

My config/email.php file:

Code:
$config['protocol'] = 'smtp';
  $config['smtp_timeout']    = 5;                // SMTP Timeout (in seconds). ( None )
  $config['smtp_host'] = 'mail.domain.com';
  $config['smtp_port'] = '25';
  $config['charset'] = 'UTF-8';
  $config['wordwrap'] = TRUE;

If I run this as-is, I, get:
<b>Fatal error:</b> Maximum execution time of 300 seconds exceeded in D:\www\system\libraries\Email.php on line 1839

Seems like it it not accepting the override smtp_timeout anyway. Am i loading this correctly?