i want to send a copy of password to a student using their email..
i used callback_after_insert to send the email but it didnt work what is the problem?
⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠
Posted 22 August 2013 - 07:38 AM
i want to send a copy of password to a student using their email..
i used callback_after_insert to send the email but it didnt work what is the problem?
Posted 22 August 2013 - 08:02 AM
Please show us your controller and we might be able to tell you
Posted 22 August 2013 - 08:29 AM
Posted 22 August 2013 - 08:31 AM
sir if you refer to your code ...
//$this->grocery_crud->callback_after_insert(array($this,'hidden'));
how can you expect php to execute this piece of code?
Posted 22 August 2013 - 08:32 AM
this is my calback after insert
function sendEmail($post_array,$primary_key)
{
}
Posted 22 August 2013 - 10:33 AM
$crud->callback_after_insert(array($this, 'name_of_callback_function'));
then
function name_of_callback_function($post_array,$primary_key) { //your code for what you want to do return true; }
Don't comment out the line.
Posted 22 August 2013 - 12:00 PM
i include this and it's still didnt work
$this->grocery_crud->callback_after_insert(array($this,'sendEmail'));
Posted 22 August 2013 - 12:07 PM
Posted 22 August 2013 - 12:11 PM
how you saying it is not working as? you not receiving mail or is it some other way you commencing on it. Not receiving mail may be reason of configuration of server.
what i will suggest you do is.. try making some log entry in file / database to check if it is happening or not. If it does happen.. it means mail functionality has issue.. and not code
Posted 22 August 2013 - 12:16 PM
the email code is working i already try it
Posted 22 August 2013 - 12:18 PM
but when i used it as my callback_after_insert it doesnt work
really need some help..
Posted 22 August 2013 - 14:00 PM
Do you have an email config file stored in application/config/email.php?
if you don't then you need something like this:
$config['protocol'] = 'sendmail'; $config['mailpath'] = '/usr/sbin/sendmail'; $config['charset'] = 'iso-8859-1'; $config['wordwrap'] = TRUE; $this->email->initialize($config);
after
$this->load->library('email');
and before you issue the send command
See: http://ellislab.com/codeigniter/user-guide/libraries/email.html - Setting Email Preferences
so you function might look like this
function sendEmail($post_array,$primary_key) { $this->load->library('email'); // email config start --------------- $config['protocol'] = 'sendmail'; $config['mailpath'] = '/usr/sbin/sendmail'; $config['charset'] = 'iso-8859-1'; $config['wordwrap'] = TRUE; $this->email->initialize($config); // email config end -------------------- $this->email->set_newline("\r\n"); $this->email->from('revshare18@gmail.com','reu'); $this->email->to('reubenbaltazar@yahoo.com'); $this->email->subject('sample'); $this->email->message('testing'); $this->email->send(); return true; }
Posted 22 August 2013 - 14:16 PM
yes a already tested the mail function and its fine...
how to check if the callback_after_insert is working?
i think the callback function isn't working
Posted 22 August 2013 - 14:54 PM
what is in your file: application/config/email.php ?
Posted 22 August 2013 - 15:57 PM
<?php if(! defined('BASEPATH')) exit('No direct script acess allowed');
Posted 22 August 2013 - 17:48 PM
$config['smtp_host']='ssl://smtp.googlemail.com';
I don't think you can use that as a host name it should be just smtp.googlemail.com
Posted 23 August 2013 - 03:11 AM
i already check the email config and it works fine...
i have no problems in my config email..
my problem is the callback_after_insert its not working.
how to check if this function is executing?
Posted 23 August 2013 - 03:32 AM
can you share your environment with me.. like php version / codeigniter version and grocerycrud version.
Also .. what i will suggest you to do is.. do a print / echo of some statement in the function and make it die. ...
then look @the firebug to see the response from insert.. if it gets stuck up with the output ..meaning the function is getting called in but if it dose not .. then it might be a situation to look into.
Make sure you write die() post the print statement.. and try and keep it ahead of all the code in the function so we are sure it is not dying cuz of some other issue.
Posted 23 August 2013 - 09:11 AM
function sendEmail($post_array,$primary_key){$this->load->library('email');$this->email->set_newline("\r\n");$this->email->from('revshare18@gmail.com','reu');$this->email->to('reubenbaltazar@yahoo.com');$this->email->subject('sample');$this->email->message('testing');$this->email->send();return true;}then this is my callback_after_insert function still does not working
Hello and welcome to the forums [member=reuben baltazar].
Please remove this line: $this->email->set_newline("\r\n");
Check here why.
Posted 23 August 2013 - 10:25 AM
i already check the email config and it works fine...
i have no problems in my config email..
my problem is the callback_after_insert its not working.
how to check if this function is executing?
One problem you have is that your callback function calls the mail send library which tries to use the SMTP host: ssl://smtp.googlemail.com
That host does not exist - try pinging it and you will see
ping ssl://smtp.googlemail.com ping: unknown host ssl://smtp.googlemail.com
So the mail function returns an error to your callback. Hostnames can only contain letters, numbers and hyphens (-) but not / or : and are always
something.something1.something2
Try pinging smtp.googlemail.com and you will get something like
ping smtp.googlemail.com PING googlemail-smtp.l.google.com (74.125.136.16) 56(84) bytes of data. 64 bytes from ea-in-f16.1e100.net (74.125.136.16): icmp_req=1 ttl=45 time=34.1 ms 64 bytes from ea-in-f16.1e100.net (74.125.136.16): icmp_req=2 ttl=45 time=32.7 ms 64 bytes from ea-in-f16.1e100.net (74.125.136.16): icmp_req=3 ttl=45 time=31.4 ms
which shows that exists.
Nothing can send mail to a non-existent host.