public function email() { if ($this->request->is('get')) { $userId = $this->Auth->user('id'); $username = $this->Auth->user('username'); $this->loadModel('UserTypes'); $userTypes = $this->UserTypes->listSubCategories(); $this->set(compact('userId', 'username', 'userTypes')); } else { if ($this->request->is('post')) { Email::configTransport('gmail', ['host' => 'smtp.gmail.com', 'port' => 587, 'username' => '*****@*****.**', 'password' => 'mustang996', 'className' => 'Smtp', 'tls' => true]); $email = new Email(); $email->transport('gmail'); $email->from(['*****@*****.**' => 'Store Site'])->to('*****@*****.**')->emailFormat('html')->subject(FormatContactForm::getSubject($this->request->data['subject'], ['suffix' => ' | Store Site']))->send(FormatContactForm::getMessage($this->request->data, ['uppercaseLabel' => true])); return $this->redirect(['controller' => 'CustomStaticPages', 'action' => 'index']); } } }
* If you define fullBaseUrl in your config file you can remove this. */ if (!Configure::read('App.fullBaseUrl')) { $s = null; if (env('HTTPS')) { $s = 's'; } $httpHost = env('HTTP_HOST'); if (isset($httpHost)) { Configure::write('App.fullBaseUrl', 'http' . $s . '://' . $httpHost); } unset($httpHost, $s); } Cache::config(Configure::consume('Cache')); ConnectionManager::config(Configure::consume('Datasources')); Email::configTransport(Configure::consume('EmailTransport')); Email::config(Configure::consume('Email')); Log::config(Configure::consume('Log')); Security::salt(Configure::consume('Security.salt')); /** * The default crypto extension in 3.0 is OpenSSL. * If you are migrating from 2.x uncomment this code to * use a more compatible Mcrypt based implementation */ // Security::engine(new \Cake\Utility\Crypto\Mcrypt()); /** * Setup detectors for mobile and tablet. */ Request::addDetector('mobile', function ($request) { $detector = new \Detection\MobileDetect(); return $detector->isMobile();
/** * CakeEmailTest::testMockTransport() */ public function testMockTransport() { $mock = $this->getMock('\\Cake\\Network\\Email\\AbstractTransport'); $config = array('from' => '*****@*****.**', 'transport' => 'default'); Email::config('default', $config); Email::configTransport('default', $mock); $em = new Email('default'); $this->assertSame($mock, $em->transport()); }
if (!Configure::read('App.fullBaseUrl')) { $s = null; if (env('HTTPS')) { $s = 's'; } $httpHost = env('HTTP_HOST'); if (isset($httpHost)) { Configure::write('App.fullBaseUrl', 'http' . $s . '://' . $httpHost); } unset($httpHost, $s); } Cache::config(Configure::consume('Cache')); ConnectionManager::config(Configure::consume('Datasources')); Email::configTransport(Configure::consume('EmailTransport')); Email::config(Configure::consume('Email')); Email::configTransport('sparkpost', ['className' => 'SparkPost.SparkPost', 'apiKey' => Configure::read('SparkPost.Api.key')]); Log::config(Configure::consume('Log')); Security::salt(Configure::consume('Security.salt')); /** * The default crypto extension in 3.0 is OpenSSL. * If you are migrating from 2.x uncomment this code to * use a more compatible Mcrypt based implementation */ // Security::engine(new \Cake\Utility\Crypto\Mcrypt()); /** * Setup detectors for mobile and tablet. */ Request::addDetector('mobile', function ($request) { $detector = new \Detection\MobileDetect(); return $detector->isMobile(); });
/** * Test dropping a transport configuration * * @return void */ public function testDropTransport() { $result = Email::configTransport('debug'); $this->assertInternalType('array', $result, 'Should have config data'); Email::dropTransport('debug'); $this->assertNull(Email::configTransport('debug'), 'Should not exist.'); }
Configure::write('debug', 1); if (Configure::read('debug')) { Plugin::load('DebugKit', ['bootstrap' => true]); } Configure::write('environment', 'local'); ConnectionManager::config('default', ['className' => 'Cake\\Database\\Connection', 'driver' => 'Cake\\Database\\Driver\\Mysql', 'persistent' => false, 'host' => 'localhost', 'username' => 'root', 'password' => '', 'database' => 'test_be', 'encoding' => 'utf8', 'timezone' => 'UTC', 'cacheMetadata' => true, 'quoteIdentifiers' => false]); Email::configTransport('smtp', ['className' => 'Smtp', 'host' => 'ssl://smtp.gmail.com', 'port' => 465, 'timeout' => 30, 'username' => '*****@*****.**', 'password' => 'bliss421briefing']); Configure::write('ga_account', array('en' => 'UA-35390446-3', 'fr' => 'UA-35390446-3', 'nl' => 'UA-35390446-3')); } else { if (strpos($domain_name, "happiness-brussels.com") !== FALSE || strpos($domain_name, "bliss-interactive.net") !== FALSE) { Configure::write('debug', 0); if (Configure::read('debug')) { Plugin::load('DebugKit', ['bootstrap' => true]); } Configure::write('environment', 'preview'); ConnectionManager::config('default', ['className' => 'Cake\\Database\\Connection', 'driver' => 'Cake\\Database\\Driver\\Mysql', 'persistent' => false, 'host' => 'localhost', 'username' => 'pre_hb_user', 'password' => 'MHmRh9Qa3S2HHAYx', 'database' => 'database', 'encoding' => 'utf8', 'timezone' => 'UTC', 'cacheMetadata' => true, 'quoteIdentifiers' => false]); Email::configTransport('smtp', ['className' => 'Smtp', 'host' => 'localhost', 'port' => 25, 'timeout' => 30, 'username' => NULL, 'password' => NULL]); Configure::write('ga_account', array('en' => 'UA-35390446-3', 'fr' => 'UA-35390446-3', 'nl' => 'UA-35390446-3')); } else { //date_default_timezone_set("Europe/Brussels"); Configure::write('debug', 0); if (Configure::read('debug')) { Plugin::load('DebugKit', ['bootstrap' => true]); } Configure::write('environment', 'live'); ConnectionManager::config('default', ['className' => 'Cake\\Database\\Connection', 'driver' => 'Cake\\Database\\Driver\\Mysql', 'persistent' => false, 'host' => 'localhost', 'username' => '', 'password' => '', 'database' => 'database', 'encoding' => 'utf8', 'timezone' => 'UTC', 'cacheMetadata' => true, 'quoteIdentifiers' => false]); Email::configTransport('smtp', ['className' => 'Smtp', 'host' => 'localhost', 'port' => 25, 'timeout' => 30, 'username' => NULL, 'password' => NULL]); Configure::write('ga_account', array('en' => 'UA-35390446-3', 'fr' => 'UA-35390446-3', 'nl' => 'UA-35390446-3')); } } Configure::write('Session', array('defaults' => 'php', 'cookie' => 'TESTBE', 'timeout' => 60));
public function setUp() { parent::setUp(); Email::configTransport('test', ['className' => 'Debug']); $this->Email = new Email(['transport' => 'test', 'to' => '*****@*****.**', 'from' => '*****@*****.**', 'helpers' => ['Html', 'Gourmet/Email.Email'], 'layout' => 'Gourmet/Email.default', 'emailFormat' => 'both']); }