public function compras()
{
$Email = new CakeEmail();
$Email->config('gmail');
$this->loadModel('Soya');
$this->paginate = array(
'conditions' => array('Grupo.categoria' => 'Soya','Grupo.subcategoria' => 'Productor de Oleaginosas'),
'limit' => 25
);
$this->set(array('soyas', $this->paginate('Soya')));
$Email->to('xxxx@gmail.com');
$Email->subject('Include your subject');
$Email->from('xxxx@gmail.com');
if ($Email->send())
{
return true;
} else {
echo $this->Email->smtpError;
}
}
how can i send email in cakephp - to gmail account from localhost
Question
i'm begginer in this and i found with this problem...i wan to send email from my localhost to a gmail account (this last can change for a hotmail), but first i want to prove for a gmail account. i had configure my email.php and it seems like this:
public $gmail = array(
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'username' => 'xxxxx@gmail.com',
'password' => 'xxxx',
'transport' => 'Smtp'
);
and in my controller i have this
public function compras()
{
$Email = new CakeEmail();
$Email->config('gmail');
$this->loadModel('Soya');
$this->paginate = array(
'conditions' => array('Grupo.categoria' => 'Soya','Grupo.subcategoria' => 'Productor de Oleaginosas'),
'limit' => 25
);
$this->set('soyas', $this->paginate('Soya'));
$this->Email->to = 'xxxx@gmail.com';
$this->Email->subject = 'Include your subject';
$this->Email->from = 'xxxx@gmail.com';
//$this->Email->template = 'template'; // file name template.ctp will be included in /views/elements/email/text/template.ctp
$this->Email->delivery = 'smtp';
if ($this->Email->send()
) {
return true;
} else {
echo $this->Email->smtpError;
}
}
but when i compile the errors appears
**Indirect modification of overloaded property SoyasController::$Email has no effect [APP/Controller/SoyasController.php, line 124]
Error: Call to a member function send() on a non-object **
please help!!!thanks a lot!!!
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow