Welcome Guest, Not a member yet? Register   Sign In
Email server offline errors
#1

[eluser]berg[/eluser]
Hello. I'm using the email library. And when my SMTP server is offline. I get errors printed out to my web-page before the send() function returns FALSE.

email.php in my config folder
Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'localhost';
$config_mail['smtp_port'] = '25';
$config['wordwrap'] = TRUE;
errors displayed on my webpage:
Code:
A PHP Error was encountered

Severity: Warning

Message: fsockopen() [function.fsockopen]: unable to connect to localhost:25 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. )

Filename: libraries/Email.php

Line Number: 1652
A PHP Error was encountered

Severity: Warning

Message: fwrite(): supplied argument is not a valid stream resource

Filename: libraries/Email.php

Line Number: 1795
A PHP Error was encountered

Severity: Warning

Message: fgets(): supplied argument is not a valid stream resource

Filename: libraries/Email.php

Line Number: 1818
A PHP Error was encountered

Severity: Warning

Message: fwrite(): supplied argument is not a valid stream resource

Filename: libraries/Email.php

Line Number: 1795
A PHP Error was encountered

Severity: Warning

Message: fgets(): supplied argument is not a valid stream resource

Filename: libraries/Email.php

Line Number: 1818
A PHP Error was encountered

Severity: Warning

Message: fwrite(): supplied argument is not a valid stream resource

Filename: libraries/Email.php

Line Number: 1795
A PHP Error was encountered

Severity: Warning

Message: fgets(): supplied argument is not a valid stream resource

Filename: libraries/Email.php

Line Number: 1818
A PHP Error was encountered

Severity: Warning

Message: fwrite(): supplied argument is not a valid stream resource

Filename: libraries/Email.php

Line Number: 1795
A PHP Error was encountered

Severity: Warning

Message: fwrite(): supplied argument is not a valid stream resource

Filename: libraries/Email.php

Line Number: 1795
A PHP Error was encountered

Severity: Warning

Message: fgets(): supplied argument is not a valid stream resource

Filename: libraries/Email.php

Line Number: 1818

I would have expected the send() function to return just False and not output these errors to my client.
#2

[eluser]bitist[/eluser]
[quote author="berg" date="1254364156"]
errors displayed on my webpage:
Code:
A PHP Error was encountered

Severity: Warning

Message: fsockopen() [function.fsockopen]: unable to connect to localhost:25 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. )
[/quote]

In my opinion too, when fsockopen fails it should return with a FALSE.
You could call the mail function with a @ so you'll get the FALSE but not the warnings.
Code:
$email_status = @$CI->email->send();
#3

[eluser]berg[/eluser]
[quote author="vanyinet" date="1254393619"]
Code:
$email_status = @$CI->email->send();
[/quote]

Thanks! That did the trick.




Theme © iAndrew 2016 - Forum software by © MyBB