CodeIgniter Forums
$this->email->send() returns nothing - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: $this->email->send() returns nothing (/showthread.php?tid=54472)

Pages: 1 2


$this->email->send() returns nothing - El Forum - 09-10-2012

[eluser]redcloud80[/eluser]
Here I can read that there's no need to initialize something

http://ellislab.com/codeigniter/user-guide/libraries/email.html

Setting Email Preferences in a Config File

If you prefer not to set preferences using the above method, you can instead put them into a config file. Simply create a new file called the email.php, add the $config array in that file. Then save the file at config/email.php and it will be used automatically. You will NOT need to use the $this->email->initialize() function if you save your preferences in a config file.


$this->email->send() returns nothing - El Forum - 09-10-2012

[eluser]TWP Marketing[/eluser]
Looking at the email library function send(), I agree it should return only true or false. I wonder if your server or php version is not converting that to numeric 1/0 or text '1'/'0'.

Conditional, check for exact boolean, numeric or text output types
Code:
if( $this->email->send() === null )
{
die('send null');
}
if( $this->email->send() === true )
{
die('send true');
}
if( $this->email->send() === false )
{
die('send false');
}
if( $this->email->send() === 1 )
{
die('send one');
}
if( $this->email->send() === 0 )
{
die('send zero');
}
if( $this->email->send() === '1' )
{
die('send string one');
}
if( $this->email->send() === '0' )
{
die('send string zero');
}



$this->email->send() returns nothing - El Forum - 09-10-2012

[eluser]CroNiX[/eluser]
Also, search the forum for sending email through gmail. I think you need to use SSL, like:
Code:
$config['smtp_host'] = 'ssl://smtp.googlemail.com';



$this->email->send() returns nothing - El Forum - 09-10-2012

[eluser]CroNiX[/eluser]
[quote author="redcloud80" date="1347312980"]Here I can read that there's no need to initialize something

http://ellislab.com/codeigniter/user-guide/libraries/email.html

Setting Email Preferences in a Config File

If you prefer not to set preferences using the above method, you can instead put them into a config file. Simply create a new file called the email.php, add the $config array in that file. Then save the file at config/email.php and it will be used automatically. You will NOT need to use the $this->email->initialize() function if you save your preferences in a config file.[/quote]
I'm pretty sure there's a bug with that that hasn't been fixed and also with doing $this->load->library('email', $config). Try manually initializing it like I suggested. It definitely wouldn't hurt anything...


$this->email->send() returns nothing - El Forum - 09-10-2012

[eluser]redcloud80[/eluser]
I've added ssl to the smtp_host, $config['smtp_timeout'] = 5 and $this->email->initialize();
before $this->email->send(). The request never ends, it's still loading... I'm sure that the smtp server is perfectly working.


$this->email->send() returns nothing - El Forum - 09-10-2012

[eluser]redcloud80[/eluser]
Finally the "answer": Fatal error: Maximum execution time of 300 seconds exceeded in...

Code:
3 0.0437 5008472 call_user_func_array ( ) ..\CodeIgniter.php:359
4 0.0437 5008552 Registration->send_confirmation_email( ) ..\CodeIgniter.php:359
5 0.0444 5009664 CI_Email->send( ) ..\registration.php:74
6 0.0447 5011480 CI_Email->_spool_email( ) ..\Email.php:1383
7 0.0447 5011608 CI_Email->_send_with_smtp( ) ..\Email.php:1514
8 1.5201 5026728 CI_Email->_get_smtp_data( ) ..\Email.php:1657

Variables in local scope (#8)

$data =
string '' (length=0)


$str =
Undefined



$this->email->send() returns nothing - El Forum - 09-10-2012

[eluser]redcloud80[/eluser]
This is how I solved

Code:
$config['crlf'] = "\r\n";
$config['newline'] = "\r\n";

:\