Welcome Guest, Not a member yet? Register   Sign In
PHP mail() works but $this->email->send() does not
#11

[eluser]louisl[/eluser]
If it sends from PHP's mail() function you shouldn't need an email config.
#12

[eluser]dangermark[/eluser]
Isn't that beside the point though?
#13

[eluser]InsiteFX[/eluser]
See if this will fix it!
Code:
class Sendemail extends CI_Controller {

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

  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();
  }
}

Now I see that your using the email.php file so you do not need the above.

InsiteFX
#14

[eluser]louisl[/eluser]
[quote author="dangermark" date="1301976185"]Isn't that beside the point though?[/quote]

What I mean is you may be unnecessarily changing defaults, if mail() works then so should CI without any server related config changes. A typical email of mine is simply this:-

Code:
$this->load->library('email');

$config['mailtype'] = 'html';

$this->email->initialize($config);
    
$this->email->from($from_email, $from_name);
$this->email->to($to);
$this->email->subject($subject);
$this->email->message($message_html);
$this->email->set_alt_message($message_plain);
$this->email->send();
#15

[eluser]InsiteFX[/eluser]
@louis!

There is no defaults for SMTP you have to set the config parameters for SMTP to work correct!

InsiteFX
#16

[eluser]louisl[/eluser]
[quote author="InsiteFX" date="1301977675"]@louis!

There is no defaults for SMTP you have to set the config parameters for SMTP to work correct!

InsiteFX[/quote]

But the default protocol is mail doesn't that route through PHP the same as mail() to whatever is set in php.ini?

Anyhow, something else to try if none of the above works give this config a go:-
Code:
$config['protocol'] = "smtp";
$config['smtp_host'] = "localhost"; //or mail.yourserver.com
$config['newline'] = "\r\n";
$config['crlf'] = "\r\n";
#17

[eluser]dangermark[/eluser]
That actually worked.

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

Thanks for your help.
#18

[eluser]bhumes[/eluser]
[quote author="louisl" date="1301980669"]
Code:
$config['newline'] = "\r\n";
$config['crlf'] = "\r\n";
[/quote]

This. If you are using a Windows server for SMTP, you need to set the line breaks to the above. Otherwise, it will timeout.




Theme © iAndrew 2016 - Forum software by © MyBB