What I did
public $smtp = array(
'transport' => 'Smtp',
'from' => array('[email protected]' => 'test'),
'host' => 'mail.mydomain.com',
'port' => 80,
'timeout' => 60,
'username' => '[email protected]',
'password' => 'me123',
'client' => null,
'log' => false,
//'charset' => 'utf-8',
//'headerCharset' => 'utf-8',
);
$email = new CakeEmail('Smtp');
$result = $email->template('welcome_mail','default')
->emailFormat('html')
->to($to_email)
->from('[email protected]')
->subject('Welcome')
->viewVars($contents);
if($email ->send('Smtp'))
{
echo ('success');
}
what I am doing wrong here? Please can anyonce explain smtp settings here? what is host,username,password,client?
Please guide me what is host
which username and password I have to set here
Sending messages quickly Example: CakeEmail::deliver('[email protected]', 'Subject', 'Message', array('from' => '[email protected]')); This method will send an email to [email protected], from [email protected] with subject Subject and content Message. The return of deliver() is a CakeEmail instance with all configurations set.
After you've loaded Email , you can send an email with the following: $email = new Email('default'); $email->from(['[email protected]' => 'My Site']) ->to('[email protected]') ->subject('About') ->send('My message');
I would add the Email Config to your email.php file located in /app/Config/email.php , if it doesn't exist copy email.php.default to email.php, Change the smtp settings there
public $smtp = array(
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'username' => '[email protected]',
'password' => 'secret'
);
At the top of your Controller above class Controller extends AppController add,
App::uses('CakeEmail', 'Network/Email');
Then to send an email, try
$Email = new CakeEmail();
$Email->from(array('[email protected]' => 'My Site'))
->to('[email protected]')
->subject('About')
->send('My message');
To test emails what I usually do is send them to the Cake Logs,
**In /app/Config/email.php, include: ( The log output should be /app/tmp/logs/debug.log )
public $test = array(
'log' => true
);
Also doing this add 'test' to your $Email variable like,**
$Email = new CakeEmail('test');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With