Welcome Guest, Not a member yet? Register   Sign In
Email Library Error or what?
#1

[eluser]SitesByJoe[/eluser]
I'm getting a weird error from the email library. It happened 3-4 times today amidst a hundred or so signups. The page is also https.

I have a controller that sends an email receipt when someone creates a profile. Here's the bit of code that sends the email:

Code:
$this->load->library('email');
$this->email->initialize(array(
'protocol' => 'smtp',
'smtp_host' => $this->config->item('mail_server'),
'smtp_user' => $this->config->item('mail_username'),
'smtp_pass' => $this->config->item('mail_password'),
'mailtype' => 'html',
'charset' =>'iso-8859-1',
'wordwrap' => TRUE
));

$this->email->from('[email protected]');  
$this->email->to($this->config->item('company_email'));
$this->email->subject('New Profile Created!');

$body = '&lt;html&gt;&lt;body><h1>Profile Information</h1>';
$body .= '<p>Type: ' . $record['type'] . '<br>';
$body .= 'Name: ' . $record['first_name'] . ' ' . $record['last_name'] . '<br>';
$body .= 'DOB: ' . $dob. '<br>';
$body .= 'Email: ' . $record['email'] . '<br>';  
$body .= 'User Agent: ' . $user_agent . '</p>&lt;/body&gt;&lt;/html>';          
$this->email->message($body);            
$this->email->send();

I have any site errors emailed to myself and here's the error messages I received:

Code:
Severity: 2 --&gt; fgets(): 59 is not a valid stream resource File: /home/sitesbyjoe/collegescholarships.com/system/libraries/Email.php Line: 1812

I looked into the Email library for line 1812 which is this:

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

Which is part of the function _get_smtp_data(). What is the 512?

In addition to throwing that error, a bunch of errors occur:

Code:
Severity: 8 --&gt; fwrite() [function.fwrite]: send of 33 bytes failed with errno=32 Broken pipe File: /home/sitesbyjoe/website.com/system/libraries/Email.php Line: 1789

and

Code:
Severity: 2 --&gt; fwrite(): 61 is not a valid stream resource File: /home/sitesbyjoe/website.com/system/libraries/Email.php Line: 1789

It goes on a few more times, back and forth between the error types.

Line 1789 in the Email library is:

Code:
if ( ! fwrite($this->_smtp_connect, $data . $this->newline))

Is the function actually writing a file as it builds the email?

Any thoughts on debugging this would be deeply appreciated.

Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB