Re: SEND EMAIL FUNCTION INSIDE CONTROLLER

2011-06-08 Thread Dr. Loboto
The blank page is because of $this->autoRender = false; and no
redirect to other page (which won't work anyway while there is error).
The error looks like PHPMailer one.
Check file C:\xampp\htdocs\pcg_servidor\vendors
\PHPMailer_v5.0.2\class.phpmailer.php at line 1 053 for conditions
that give error.

On Jun 8, 5:42 pm, andreguerreiro85 
wrote:
> Tnks, i missed that! :) the error is:
> Could not instantiate mail function.
>
> Warning (2): Cannot modify header information - headers already sent by
> (output started at
> C:\xampp\htdocs\pcg_servidor\vendors\PHPMailer_v5.0.2\class.phpmailer.php:1 
> 053)
> [CORE\cake\libs\controller\controller.php, line 644]
>
> Code | Context
>
> $status =       
> "Location:http://localhost:90/pcg_servidor/encomendas/encomendas_encomendas/ind...";
>
>         }
>
>         echo $_this->_output($level, $error, $code, $helpCode, $description,
> $file, $line, $context);
>
> Debugger::handleError() - CORE\cake\libs\debugger.php, line 222
> header - [internal], line ??
> Controller::header() - CORE\cake\libs\controller\controller.php, line 644
> Controller::redirect() - CORE\cake\libs\controller\controller.php, line 625
> EncomendasEncomendasController::delete() -
> APP\plugins\encomendas\controllers\encomendas_encomendas_controller.php,
> line 523
> Object::dispatchMethod() - CORE\cake\libs\object.php, line 118
> Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 227
> Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 194
> [main] - APP\webroot\index.php, line 88
>
> --
> View this message in 
> context:http://cakephp.1045679.n5.nabble.com/SEND-EMAIL-FUNCTION-INSIDE-CONTR...
> Sent from the CakePHP mailing list archive at Nabble.com.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: SEND EMAIL FUNCTION INSIDE CONTROLLER

2011-06-08 Thread andreguerreiro85
Tnks, i missed that! :) the error is: 
Could not instantiate mail function.

Warning (2): Cannot modify header information - headers already sent by
(output started at
C:\xampp\htdocs\pcg_servidor\vendors\PHPMailer_v5.0.2\class.phpmailer.php:1053)
[CORE\cake\libs\controller\controller.php, line 644]

Code | Context

$status =   "Location:
http://localhost:90/pcg_servidor/encomendas/encomendas_encomendas/index/datai:2011-04-01/dataf:2011-04-07/";

}

echo $_this->_output($level, $error, $code, $helpCode, $description,
$file, $line, $context);

Debugger::handleError() - CORE\cake\libs\debugger.php, line 222
header - [internal], line ??
Controller::header() - CORE\cake\libs\controller\controller.php, line 644
Controller::redirect() - CORE\cake\libs\controller\controller.php, line 625
EncomendasEncomendasController::delete() -
APP\plugins\encomendas\controllers\encomendas_encomendas_controller.php,
line 523
Object::dispatchMethod() - CORE\cake\libs\object.php, line 118
Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 227
Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 194
[main] - APP\webroot\index.php, line 88



--
View this message in context: 
http://cakephp.1045679.n5.nabble.com/SEND-EMAIL-FUNCTION-INSIDE-CONTROLLER-tp4461556p4469125.html
Sent from the CakePHP mailing list archive at Nabble.com.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: SEND EMAIL FUNCTION INSIDE CONTROLLER

2011-06-08 Thread Dr. Loboto
Remove configure::write('debug', 0); from your mail function and see
actual error.

On Jun 7, 7:08 pm, andreguerreiro85 
wrote:
> Hi there, i'm having a problem calling a function to send email inside
> another function in a controller. i'm calling the function here on function
> delete, the functions is mail():
>
>         function delete($id)
>
>         {
>                 $this->ApiHandler->access('admin', 'dcgl');
>
>                 $this->EncomendasEncomenda->id = $id;
>
>                 $this->EncomendasEncomenda->recursive = -1;
>
>                 $data = $this->EncomendasEncomenda->read();
>
>                 if ($data['EncomendasEncomenda']['activa'] == 1)
>                 {
>                         $newState = 0;
>                 }
>                 else
>                 {
>                         $newState = 1;
>                 }
>
>                 if ($this->EncomendasEncomenda->saveField('activa', 
> $newState))
>
>                 {      
>                         $this->mail($id);
>                         $this->Session->setFlash('Estado da Encomenda 
> alterado');
>
>                 }
>                 else
>                 {
>                         $this->Session->setFlash('Não é possível alterar o 
> estado da
> Encomenda');
>                 }
>         $this->redirect($this->referer());        
>         }  }
>
> My function mail()  work's fine but when i call it from the function i get a
> blank page and no email sended
>
>   function mail($encomendaId)
>     {
>         configure::write('debug', 0);
>
>         $this->autoRender = false;
>
>         App::import('vendor', 'PHPMailer', array('file' =>
> 'PHPMailer_v5.0.2/class.phpmailer.php'));
>
>         $mail = new PHPMailer();
>
>         $mail->SMTPDebug = 0;
>
>                 $mail->SMTPAuth   = true;                // enable SMTP 
> authentication
>                 $mail->Port       = 25;                  // set the SMTP port
>
>                 $mail->Host       = Configure::read('Email.host'); // SMTP 
> server
>
>                 $mail->Username   = Configure::read('Email.username'); // 
> SMTP account
> username
>
>                 $mail->Password   = Configure::read('Email.password');     // 
> SMTP account
> password
>
>                 $mail->SetFrom(Configure::read('Email.address'), 'PCG');
>
>                 $mail->AddAddress('andreguerre...@sogenave.pt', 'ADMIN');
>
>                         $print_link = sprintf('http://%s%s', 
> configure::read('PCG.server'),
> Router::url(array('action' => 'view', $encomendaId.'.print')));
>
>         $html = file_get_contents($print_link);        
>
>         if (empty($html))
>
>         {
>                 $this->log('Envio do e-mail EMPTY ' . $print_link, 'emails');
>
>                 exit(0);
>
>         }
>
>         $text = strip_tags($html);
>
>         $subject = 'PCG: Encomenda #'.$encomendaId;
>
>         $mail->Subject = $subject;
>
>         $mail->AltBody = $text;
>
>         $mail->MsgHTML($html);
>
>         $this->log('Envio do e-mail ' . $subject, 'emails');
>
>  if(!$mail->Send())
>         {
>             $this->log($mail->ErrorInfo, 'emails');
>         }
>         else
>         {
>             $this->log('Envio do e-mail ' . $subject . ' OK', 'emails');
>         }
>
> Thanks in advance.
>
> --
> View this message in 
> context:http://cakephp.1045679.n5.nabble.com/SEND-EMAIL-FUNCTION-INSIDE-CONTR...
> Sent from the CakePHP mailing list archive at Nabble.com.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


SEND EMAIL FUNCTION INSIDE CONTROLLER

2011-06-07 Thread andreguerreiro85
Hi there, i'm having a problem calling a function to send email inside
another function in a controller. i'm calling the function here on function
delete, the functions is mail():

function delete($id)

{
$this->ApiHandler->access('admin', 'dcgl');

$this->EncomendasEncomenda->id = $id;

$this->EncomendasEncomenda->recursive = -1;

$data = $this->EncomendasEncomenda->read();

if ($data['EncomendasEncomenda']['activa'] == 1)
{
$newState = 0;
}
else
{
$newState = 1;
}

if ($this->EncomendasEncomenda->saveField('activa', $newState))

{   
$this->mail($id);
$this->Session->setFlash('Estado da Encomenda 
alterado');   

}
else
{
$this->Session->setFlash('Não é possível alterar o 
estado da
Encomenda');
}
$this->redirect($this->referer());  
}  
}
My function mail()  work's fine but when i call it from the function i get a
blank page and no email sended

  function mail($encomendaId)
{
configure::write('debug', 0);

$this->autoRender = false;

App::import('vendor', 'PHPMailer', array('file' =>
'PHPMailer_v5.0.2/class.phpmailer.php'));

$mail = new PHPMailer();

$mail->SMTPDebug = 0;

$mail->SMTPAuth   = true;// enable SMTP 
authentication
$mail->Port   = 25;  // set the SMTP port

$mail->Host   = Configure::read('Email.host'); // SMTP 
server

$mail->Username   = Configure::read('Email.username'); // SMTP 
account
username

$mail->Password   = Configure::read('Email.password'); // 
SMTP account
password

$mail->SetFrom(Configure::read('Email.address'), 'PCG');

$mail->AddAddress('andreguerre...@sogenave.pt', 'ADMIN');

$print_link = sprintf('http://%s%s', 
configure::read('PCG.server'),
Router::url(array('action' => 'view', $encomendaId.'.print')));

$html = file_get_contents($print_link);

if (empty($html))

{
$this->log('Envio do e-mail EMPTY ' . $print_link, 'emails');

exit(0);

}

$text = strip_tags($html);

$subject = 'PCG: Encomenda #'.$encomendaId;

$mail->Subject = $subject;

$mail->AltBody = $text;

$mail->MsgHTML($html);

$this->log('Envio do e-mail ' . $subject, 'emails');
   
 if(!$mail->Send()) 
{
$this->log($mail->ErrorInfo, 'emails');
}
else
{
$this->log('Envio do e-mail ' . $subject . ' OK', 'emails');
}

Thanks in advance.

--
View this message in context: 
http://cakephp.1045679.n5.nabble.com/SEND-EMAIL-FUNCTION-INSIDE-CONTROLLER-tp4461556p4461556.html
Sent from the CakePHP mailing list archive at Nabble.com.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Email Function

2009-10-06 Thread brian
On Tue, Oct 6, 2009 at 1:50 PM, Dave Maharaj :: WidePixels.com
 wrote:
> My controller is getting out of control
>
> I have 3 different registration functions which all send emails
>
> such as:
>
> if ($this->User->save($this->data, true,
> array_intersect(array_keys($this->User->schema()), $white))) {
>   $this->Email->smtpOptions = array(my info here);
>   $this->Email->delivery = 'smtp';
>   $this->Email->to = $this->data['User']['email'];
>   $this->Email->subject = 'Account Confirmation';
>   $this->Email->replyTo = 'noreply@;
>   $this->Email->from = ';
>   $this->Email->sendAs = 'html';
>   $this->Email->template = 'registration';
>   $this->set('data', $this->data);
>   $this->set('ip_address', $_SERVER['REMOTE_ADDR']);
>   $this->set('server_name', $_SERVER['SERVER_NAME']);
>
>   if ($this->Email->send()) {
>     do something here but each registration does something
> different
>  }
>
> I need to turn this into a function which will return true or false if
> $this->Email->send() to continue on.
>
> Any ideas? I tred a few things but it never worked.
>
>
>
> function sendRegistrationEmail($data, $role) {
>   $sendSuccess = false;
>   /* SMTP Options */
>   ...
>
>   if ($this->Email->send()) {
>   $sendSuccess = true;
>   //create the Freelancer page
>   }
>   return $sendSuccess;
>
>   }
>
> Dave


if ($this->User->save(...))
{
// email stuff
$data = array(
'subject' => '...',
'to' => '...'
// etc.
);

if ($this->sendRegistrationEmail($data))
{
// do your role stuff here
}

}


function sendRegistrationEmail($data)
{
$this->Email->subject = $data['subject'];
// etc.

return $this->Email->send();
}

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Email Function

2009-10-06 Thread Dave Maharaj :: WidePixels.com
My controller is getting out of control
 
I have 3 different registration functions which all send emails
 
such as:
 
if ($this->User->save($this->data, true,
array_intersect(array_keys($this->User->schema()), $white))) {
  $this->Email->smtpOptions = array(my info here);
  $this->Email->delivery = 'smtp';
  $this->Email->to = $this->data['User']['email'];
  $this->Email->subject = 'Account Confirmation';
  $this->Email->replyTo = 'noreply@;
  $this->Email->from = ';
  $this->Email->sendAs = 'html';
  $this->Email->template = 'registration';
  $this->set('data', $this->data);
  $this->set('ip_address', $_SERVER['REMOTE_ADDR']);
  $this->set('server_name', $_SERVER['SERVER_NAME']);
 
  if ($this->Email->send()) {
do something here but each registration does something
different
 }
 
I need to turn this into a function which will return true or false if
$this->Email->send() to continue on.
 
Any ideas? I tred a few things but it never worked.
 
 
 
function sendRegistrationEmail($data, $role) {
  $sendSuccess = false;
  /* SMTP Options */
  ...
 
  if ($this->Email->send()) {
  $sendSuccess = true;
  //create the Freelancer page
  }
  return $sendSuccess;

  }
 
Dave

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: email function

2009-07-01 Thread Paul Webster

We do that very thingy by wrapping the standard, often repeated email
code in another component that uses the Email component,

Then you just have to do something along the lines of [in your
controller]:

var $component => array('Notify' => array('email config params'));

$this->Notify->send('all your email specific options here');






On Jul 2, 6:57 am, "Dave Maharaj :: WidePixels.com"
 wrote:
> Is there a easy way to set this up so it could be called from different
> controllers? Instead of putting that chunk repeated in different controllers
>
> So in a controller call the function anywhere
> $this->Model->Email->send($template , $subject)
>
> $this->Email->smtpOptions = array('port' => '26', 'timeout' => '30', 'host'
> => 'localhost', 'username' => 'd...@widepixels.com', 'password' =>
> 'xx');
>                   /* Set delivery method */
>                   $this->Email->delivery = 'smtp';
>                   $this->Email->to = $this->data['User']['email'];
>                   $this->Email->subject = 'welcome message';
>                   $this->Email->replyTo =   ;
>                   $this->Email->from = 'me';
>                   $this->Email->sendAs = 'html';
>                   $this->Email->template = 'confirmation';
>                   $this->set('name', $this->data['User']['username']);
>                 $this->set('ip_address', $_SERVER['REMOTE_ADDR']);
>                   $this->set('server_name', $_SERVER['SERVER_NAME']);
>                   $this->set('slug', $this->data['User']['slug']);
>                   $this->set('code', $this->data['User']['confirm_code']);
>
> Dave
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



email function

2009-07-01 Thread Dave Maharaj :: WidePixels.com

Is there a easy way to set this up so it could be called from different
controllers? Instead of putting that chunk repeated in different controllers

So in a controller call the function anywhere
$this->Model->Email->send($template , $subject)
 
$this->Email->smtpOptions = array('port' => '26', 'timeout' => '30', 'host'
=> 'localhost', 'username' => 'd...@widepixels.com', 'password' =>
'xx');
  /* Set delivery method */
  $this->Email->delivery = 'smtp';
  $this->Email->to = $this->data['User']['email'];
  $this->Email->subject = 'welcome message';
  $this->Email->replyTo =   ;
  $this->Email->from = 'me';
  $this->Email->sendAs = 'html';
  $this->Email->template = 'confirmation';
  $this->set('name', $this->data['User']['username']);
$this->set('ip_address', $_SERVER['REMOTE_ADDR']);
  $this->set('server_name', $_SERVER['SERVER_NAME']);
  $this->set('slug', $this->data['User']['slug']);
  $this->set('code', $this->data['User']['confirm_code']);
 
Dave 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---