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

[eluser]apobukay[/eluser]
i use google smtp and it works fine in localhost when send email.
then I uploaded my CI file into host server and it gives me an email error when I send email.

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



what's wrong? do I need to setup anything?

please help me. thank you.
#2

[eluser]apobukay[/eluser]
I already know the problem
and I already fixed it! I'm done it works fine on live server and localhost!
#3

[eluser]InsiteFX[/eluser]
Care to explain how you fixed!

So that other user can fix it if they have the same problem.

InsiteFX
#4

[eluser]apobukay[/eluser]
Step 1
Go to email.php file library located in system\libraries\Email.php
and look for this code or lines.

Step 2
Change the lines

line 37
var $smtp_port = "25";
change it to

var $smtp_port = "465"; // Gmail smtp port because I use gmail email
----------------------------
line 41
var $mailtype = "text";
change it to (optional )

var $mailtype = "html";
--------------------------
line 47
var $newline = "\n";
change it to

var $newline = "\r\n";
------------------------
line 48
var $crlf = "\n";
change it to

var $crlf = "\r\n";
-----------------------------------------

Step 3
write this code in your Controller Class

function anything_You_want()
{
$this->load->library('email');
$this->email->set_newline("\r\n");


$this->email->from('[email protected]','YourNameHere');
$this->email->to('you To string');

$this->email->subject('your subject string');
$this->email->message('your message string');

if($this->email->send())
{
echo 'Message Sent';
}
else
{
echo $this->email->print_debugger();

//you can use this for error message instead of print_debugger()
echo 'seding message failed';

}
}



Ok I hope it will help everybody. Smile

apobukay
#5

[eluser]Twisted1919[/eluser]
LOL.
What you've done could be accomplished by using the config and the initialize() method (don't pass the config array to the library constructor, just initialize the config with the method).
At most, if for some reason that wouldn't work, you would extend the email class with your own, but to do what you did, bad decision.
#6

[eluser]apobukay[/eluser]
what's the difference?
#7

[eluser]Twisted1919[/eluser]
You gotta be kidding me right ?

If you need to connect to a google account and to other kind of account from same app, what do you do ?
#8

[eluser]apobukay[/eluser]
i don't know what to do..

will you please tell me what to do?

thanks
#9

[eluser]Twisted1919[/eluser]
Revert back all your changes done to the email library, and instantiate the library class like:
Code:
$this->load->library('email');
$config=array();
$config['protocol']     = 'smtp';      
$config['smtp_host']    = 'ssl://smtp.gmail.com';
$config['smtp_user']    = '[email protected]';
$config['smtp_pass']    = 'password';
$config['smtp_port']    = 465;
$config['smtp_timeout'] = 30;  
$config['mailtype'] = 'html';
$config['priority'] = 1 ;
$config['crlf']     = '\r\n';
$config['new_line'] = '\r\n';
        
$this->email->initialize($config);
// continue with $this->email-> to attach subject/message/etc
#10

[eluser]apobukay[/eluser]
this is very useful it helps me a lot! thanks!




Theme © iAndrew 2016 - Forum software by © MyBB