Welcome Guest, Not a member yet? Register   Sign In
Problems sending mail using SMTP
#1

[eluser]salbertson[/eluser]
I am trying to send mail using SMTP but keep getting a sendmail error in my error log. I am trying to send mail using an outside mail server.

Here is my email config:
Code:
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'mailserver.domain.com';
$config['smtp_user'] = '[email protected]';
$config['smtp_pass'] = 'password';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$config['mailtype'] = "html";
Here is my email send code, the send function returns false:
Code:
// load email library
$this->load->library('email');

// construct email
$this->email->from('[email protected]', 'Support');
$this->email->to($_POST['email']);
$this->email->bcc('[email protected]');
$this->email->subject('Support');
$this->email->message("Anything");

if(!$this->email->send())
{
// error while sending email
show_error("An error occurred while sending your login email.");
exit;
}
Here is the error I get in Apache log:
Code:
sh: /usr/sbin/sendmail: No such file or directory
Any help would be greatly appreciated, thanks.
#2

[eluser]salbertson[/eluser]
I found the problem. I was setting the email config array in a separate file config/email.php and this worked on my windows test box but obviously not my linux box due to case sensitivity. It needs to be named Email.php. I guess if no config settings are present the email class tries to use sendmail. Makes sense now and I hope this helps someone else.
#3

[eluser]Unknown[/eluser]
I saw the same problem, but fixed it in a different way. I changed _ci_init_class() in Loader.php to the following:

// Is there an associated config file for this class?
if ($config === NULL)
{
$config = NULL;
if (file_exists(APPPATH.'config/'.$class.EXT))
{
include(APPPATH.'config/'.$class.EXT);
}
elseif (file_exists(APPPATH.'config/'.strtolower($class).EXT))
{
include(APPPATH.'config/'.strtolower($class).EXT);
}

That way it checks for both the mixed and lowercase versions of the config name. I think a lot of other things are checked for this way as well. Not sure why they missed this one...




Theme © iAndrew 2016 - Forum software by © MyBB