public function __construct() { if (AppConfig::read('Smtp.enabled')) { $config = array('transport' => 'Smtp', 'from' => array(AppConfig::read('Smtp.email') => AppConfig::read('Smtp.name')), 'host' => AppConfig::read('Smtp.host'), 'port' => AppConfig::read('Smtp.port'), 'timeout' => 30, 'username' => AppConfig::read('Smtp.login'), 'password' => AppConfig::read('Smtp.password'), 'client' => null, 'log' => false, 'charset' => 'utf-8', 'headerCharset' => 'utf-8'); } else { $config = array('transport' => 'Mail', 'from' => array(AppConfig::read('Smtp.email') => AppConfig::read('Smtp.name')), 'charset' => 'utf-8', 'headerCharset' => 'utf-8'); } $this->default = $config; }
public function send_mail() { if (!$this->request->is('ajax')) { throw new NotFoundException(); } if (!$this->request->is('post')) { throw new NotFoundException(); } $content = 'Imię i Nazwisko: <b>' . $this->request->data['Contact']['name'] . '</b><br>'; $content .= 'Firma: <b>' . $this->request->data['Contact']['company'] . '</b><br>'; $content .= 'Nr telefonu: <b>' . $this->request->data['Contact']['phone'] . '</b><br>'; $content .= 'E-mail: <b>' . $this->request->data['Contact']['email'] . '</b><br>'; $content .= 'Treść wiadomości:<br>----------------------------<br>' . nl2br($this->request->data['Contact']['message'] . '<br>----------------------------'); $Email = new CakeEmail(); $Email->template('default', 'default')->emailFormat('html')->from($this->request->data['Contact']['email'])->to(AppConfig::read('Site.email'))->subject('Zapytanie z formularza kontaktowego Termat.pl')->send($content); if ($this->request->data['Contact']['copy'] == 1) { $Email = new CakeEmail(); $Email->template('default', 'default')->emailFormat('html')->from($this->request->data['Contact']['email'])->to($this->request->data['Contact']['email'])->subject('Zapytanie z formularza kontaktowego Termat.pl [kopia]')->send($content); } die; }
public function adminSendMail($to, $subject, $content, $vars) { $content = file_get_contents(APP . 'View' . DS . 'Emails' . DS . 'html' . DS . 'contents' . DS . $content . '.ctp'); foreach ($vars as $key => $value) { $content = str_replace('{{' . $key . '}}', $value, $content); } $Email = new CakeEmail(); $Email->template('admin', 'admin')->emailFormat('html')->from(array(AppConfig::read('App.email') => AppConfig::read('App.name')))->to($to)->subject($subject)->send($content); }