Bagaimana jika membina aplikasi di dalam platform Windows dan ingin menggunakan email melalui protokol SMTP ?
Di dalam tutorial ini saya akan membina controller bernama notify_controller.php dan tanpa menggunakan model. Sila lihat kod di bawah :
<?php class NotifyController extends AppController { var $name = 'Notify'; var $components = array('Email'); var $uses = null; function index(){ $this->Email->smtpOptions = array( 'port'=>'25', 'timeout'=>'30', 'host' =>'your.smtp.host', 'username'=>'username', 'password'=>'password'); $this->Email->sendAs = 'html'; /* Set delivery method */ $this->Email->delivery = 'smtp'; $this->Email->to = "azril.nazli@gmail.com"; $this->Email->subject = 'Percubaan hantar email guna SMTP'; $this->Email->from = 'azril.nazli@gmail.com'; $content = "Ini adalah percubaan hantar SMTP email"; if ( $this->Email->send($content) ) { $this->Session->setFlash('Email berjaya dihantar'); } else { $this->Session->setFlash('Email gagal dihantar'); } } //index } ?>
No comments:
Post a Comment