Пример #1
0
 protected function _execute(array $data)
 {
     // Send an email.
     Email::configTransport('amazon', ['host' => 'email-smtp.us-east-1.amazonaws.com', 'port' => 587, 'username' => 'AKIAJARRU5LPFHEQHKPQ', 'password' => 'AmNFFJsVG8vQGHqlXgy9nMYj9eAx2ubZ/Ghb84FVm7PC', 'className' => 'Smtp', 'tls' => true]);
     $email = new Email('default');
     $email->from(['*****@*****.**' => 'My Site'])->to('*****@*****.**')->subject('About')->send('My message');
     return true;
 }
Пример #2
0
 /**
  * setUp
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->EmailSender = $this->getMockBuilder('CakeDC\\Users\\Email\\EmailSender')->setMethods(['_getEmailInstance', 'getMailer'])->getMock();
     $this->UserMailer = $this->getMockBuilder('CakeDC\\Users\\Mailer\\UserMailer')->setMethods(['send'])->getMock();
     $this->fullBaseBackup = Router::fullBaseUrl();
     Router::fullBaseUrl('http://users.test');
     Email::configTransport('test', ['className' => 'Debug']);
 }
Пример #3
0
 /**
  * setup
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $table = TableRegistry::get('CakeDC/Users.Users');
     $table->addBehavior('CakeDC/Users/Register.Register');
     $this->Table = $table;
     $this->Behavior = $table->behaviors()->Register;
     Email::configTransport('test', ['className' => 'Debug']);
     $this->Email = new Email(['from' => '*****@*****.**', 'transport' => 'test']);
 }
 /**
  * setup
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->Table = TableRegistry::get('CakeDC/Users.SocialAccounts');
     $this->Behavior = $this->Table->behaviors()->SocialAccount;
     $this->fullBaseBackup = Router::fullBaseUrl();
     Router::fullBaseUrl('http://users.test');
     Email::configTransport('test', ['className' => 'Debug']);
     $this->Email = new Email(['from' => '*****@*****.**', 'transport' => 'test', 'template' => 'CakeDC/Users.social_account_validation']);
 }
 public function testSend()
 {
     Email::configTransport('default', ['className' => 'Debug']);
     Email::config('default', ['from' => '*****@*****.**', 'transport' => 'default']);
     Configure::write('App.encoding', 'UTF-8');
     $notification = new Notification();
     $notification->to('*****@*****.**', 'email');
     $emailTransport = new EmailTransport();
     $this->assertInternalType('array', $emailTransport->send($notification));
 }
Пример #6
0
 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->Users = TableRegistry::get('CakeDC/Users.Users');
     $this->fullBaseBackup = Router::fullBaseUrl();
     Router::fullBaseUrl('http://users.test');
     Email::configTransport('test', ['className' => 'Debug']);
     $this->configEmail = Email::config('default');
     Email::config('default', ['transport' => 'test', 'from' => '*****@*****.**']);
     $this->Email = new Email(['from' => '*****@*****.**', 'transport' => 'test']);
     Plugin::routes('CakeDC/Users');
 }
 /**
  * setUp
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->configOpauth = Configure::read('Opauth');
     $this->configRememberMe = Configure::read('Users.RememberMe.active');
     Configure::write('Opauth', null);
     Configure::write('Users.RememberMe.active', false);
     Email::configTransport('test', ['className' => 'Debug']);
     $this->configEmail = Email::config('default');
     Email::config('default', ['transport' => 'test', 'from' => '*****@*****.**']);
     $request = new Request('/users/users/index');
     $request->params['plugin'] = 'CakeDC/Users';
     $this->Controller = $this->getMockBuilder('CakeDC\\Users\\Controller\\SocialAccountsController')->setMethods(['redirect', 'render'])->setConstructorArgs([$request, null, 'SocialAccounts'])->getMock();
     $this->Controller->SocialAccounts = $this->getMockForModel('CakeDC\\Users.SocialAccounts', ['sendSocialValidationEmail'], ['className' => 'CakeDC\\Users\\Model\\Table\\SocialAccountsTable']);
 }
Пример #8
0
 /**
  * SetUp and create Trait
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $traitMockMethods = array_unique(array_merge(['getUsersTable'], $this->traitMockMethods));
     $this->table = TableRegistry::get('CakeDC/Users.Users');
     try {
         $this->Trait = $this->getMockBuilder($this->traitClassName)->setMethods($traitMockMethods)->getMockForTrait();
         $this->Trait->expects($this->any())->method('getUsersTable')->will($this->returnValue($this->table));
     } catch (PHPUnit_Framework_MockObject_RuntimeException $ex) {
         debug($ex);
         $this->fail("Unit tests extending BaseTraitTest should declare the trait class name in the \$traitClassName variable before calling setUp()");
     }
     if ($this->mockDefaultEmail) {
         Email::configTransport('test', ['className' => 'Debug']);
         $this->configEmail = Email::config('default');
         Email::config('default', ['transport' => 'test', 'from' => '*****@*****.**']);
     }
 }
Пример #9
0
$loader->addNamespace('App', APP);
//@codingStandardsIgnoreStart
@mkdir(LOGS);
@mkdir(SESSIONS);
@mkdir(CACHE);
@mkdir(CACHE . 'views');
@mkdir(CACHE . 'models');
//@codingStandardsIgnoreEnd
require_once CORE_PATH . 'config/bootstrap.php';
date_default_timezone_set('UTC');
mb_internal_encoding('UTF-8');
Configure::write('debug', true);
Configure::write('App', ['namespace' => 'App', 'encoding' => 'UTF-8', 'base' => false, 'baseUrl' => false, 'dir' => APP_DIR, 'webroot' => 'webroot', 'wwwRoot' => WWW_ROOT, 'fullBaseUrl' => 'http://localhost', 'imageBaseUrl' => 'img/', 'jsBaseUrl' => 'js/', 'cssBaseUrl' => 'css/', 'paths' => ['plugins' => [TEST_APP . 'Plugin' . DS], 'templates' => [APP . 'Template' . DS], 'locales' => [APP . 'Locale' . DS]]]);
Cache::config(['_cake_core_' => ['engine' => 'File', 'prefix' => 'cake_core_', 'serialize' => true], '_cake_model_' => ['engine' => 'File', 'prefix' => 'cake_model_', 'serialize' => true]]);
// Ensure default test connection is defined
if (!getenv('db_dsn')) {
    putenv('db_dsn=sqlite:///:memory:');
}
ConnectionManager::config('test', ['url' => getenv('db_dsn')]);
ConnectionManager::config('test_custom_i18n_datasource', ['url' => getenv('db_dsn')]);
Configure::write('Session', ['defaults' => 'php']);
Configure::write('EmailTransport', ['default' => ['className' => 'Debug']]);
Configure::write('Email', ['default' => ['transport' => 'default', 'from' => 'you@localhost']]);
Email::configTransport(Configure::consume('EmailTransport'));
Email::config(Configure::consume('Email'));
Log::config(['debug' => ['engine' => 'Cake\\Log\\Engine\\FileLog', 'levels' => ['notice', 'info', 'debug'], 'file' => 'debug'], 'error' => ['engine' => 'Cake\\Log\\Engine\\FileLog', 'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'], 'file' => 'error']]);
Router::reload();
Cake\Routing\DispatcherFactory::add('Routing');
Cake\Routing\DispatcherFactory::add('ControllerFactory');
Plugin::load('Users', ['path' => ROOT . DS, 'routes' => true]);
Cake\Utility\Security::salt('8b61f851d8cb3dfcf3b447dc67bd7bf9fe2ed91a916d4457f4969a05a637473d');
Пример #10
0
 /**
  * CakeEmailTest::testMockTransport()
  */
 public function testMockTransport()
 {
     $mock = $this->getMockBuilder('\\Cake\\Mailer\\AbstractTransport')->getMock();
     $config = ['from' => '*****@*****.**', 'transport' => 'default'];
     Email::config('default', $config);
     Email::configTransport('default', $mock);
     $em = new Email('default');
     $this->assertSame($mock, $em->transport());
 }
Пример #11
0
<?php

use Cake\Core\Plugin;
use Cake\Mailer\Email;
$emailFrom = read('App.email', 'no-reply@' . env('HTTP_HOST'));
$emailFrom = [$emailFrom => $emailFrom];
$emailProfiles = ['default' => ['from' => $emailFrom, 'sender' => $emailFrom, 'replyTo' => $emailFrom, 'layout' => 'default', 'template' => null, 'viewRender' => 'Cake\\View\\View', 'theme' => null, 'helpers' => ['Html'], 'emailFormat' => 'both', 'transport' => 'default']];
if (Plugin::loaded('Gourmet/Email')) {
    $emailProfiles['default']['layout'] = 'Gourmet/Email.default';
    $emailProfiles['default']['helpers'][] = 'Gourmet/Email.Email';
}
foreach (consume('Email.profiles', []) as $emailProfile => $emailProfileConfig) {
    $emailProfiles[$emailProfile] = $emailProfileConfig + $emailProfiles['default'];
}
Email::config($emailProfiles);
$emailTransports = ['default' => ['className' => 'Smtp', 'host' => 'localhost', 'port' => 1025, 'timeout' => 30, 'client' => null, 'tls' => null]];
foreach (consume('Email.transports', []) as $emailTransport => $emailTransportConfig) {
    $emailTransports[$emailTransport] = $emailTransportConfig + $emailTransports['default'];
}
Email::configTransport($emailTransports);
unset($emailFrom, $emailProfiles, $emailProfile, $emailProfileConfig, $emailTransport, $emailTransports, $emailTransportConfig);
Пример #12
0
<?php

use Cake\Mailer\Email;
use Cake\Core\Configure;
$findRoot = function ($root) {
    do {
        $lastRoot = $root;
        $root = dirname($root);
        if (is_dir($root . '/vendor/cakephp/cakephp')) {
            return $root;
        }
    } while ($root !== $lastRoot);
    throw new Exception('Cannot find the root of the application, unable to run tests');
};
$root = $findRoot(__FILE__);
unset($findRoot);
chdir($root);
require $root . '/vendor/cakephp/cakephp/tests/bootstrap.php';
Configure::write('EmailQueue.serialization_type', 'email_queue.json');
Email::configTransport(['default' => ['className' => 'Mail', 'additionalParameters' => true]]);
Email::config(['default' => ['transport' => 'default', 'from' => '*****@*****.**']]);
Пример #13
0
    /**
     * Test method
     *
     * @return void
     */
    public function testSendResetPasswordEmail()
    {
        $behavior = $this->table->behaviors()->Password;
        $this->fullBaseBackup = Router::fullBaseUrl();
        Router::fullBaseUrl('http://users.test');
        Email::configTransport('test', ['className' => 'Debug']);
        $this->Email = new Email(['from' => '*****@*****.**', 'transport' => 'test', 'template' => 'CakeDC/Users.reset_password', 'emailFormat' => 'both']);
        $user = $this->table->newEntity(['first_name' => 'FirstName', 'email' => '*****@*****.**', 'token' => '12345']);
        $result = $behavior->sendResetPasswordEmail($user, $this->Email, 'CakeDC/Users.reset_password');
        $this->assertTextContains('From: test@example.com', $result['headers']);
        $this->assertTextContains('To: test@example.com', $result['headers']);
        $this->assertTextContains('Subject: FirstName, Your reset password link', $result['headers']);
        $this->assertTextContains('Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Hi FirstName,

Please copy the following address in your web browser http://users.test/users/users/reset-password/12345
Thank you,
', $result['message']);
        $this->assertTextContains('Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
    <title>Email/html</title>
</head>
<body>
    <p>
Hi FirstName,
</p>
<p>
    <strong><a href="http://users.test/users/users/reset-password/12345">Reset your password here</a></strong>
</p>
<p>
    If the link is not correcly displayed, please copy the following address in your web browser http://users.test/users/users/reset-password/12345</p>
<p>
    Thank you,
</p>
</body>
</html>
', $result['message']);
        Router::fullBaseUrl($this->fullBaseBackup);
        Email::dropTransport('test');
    }
 public function setUp()
 {
     Email::configTransport('default', ['className' => 'Debug']);
 }
Пример #15
0
}
Configure::write('domainName', $domain_name);
if ($domain_name == "" || $domain_name == "localhost" || strpos($domain_name, "192.168.1") !== FALSE) {
    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' => 'template_admin', 'encoding' => 'utf8', 'timezone' => 'UTC', 'cacheMetadata' => true, 'quoteIdentifiers' => false]);
    Email::configTransport('smtp', ['className' => 'Smtp', 'host' => 'ssl://smtp.gmail.com', 'port' => 465, 'timeout' => 30, 'username' => '*****@*****.**', 'password' => 'phamhongtien510']);
} else {
    if (strpos($domain_name, "happiness-brussels.com") !== FALSE || strpos($domain_name, "bliss-interactive.net") !== FALSE || strpos($domain_name, 'happiness-saigon.com') !== FALSE) {
        Configure::write('debug', 1);
        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' => 'hs_musk_melon', 'encoding' => 'utf8', 'timezone' => 'UTC', 'cacheMetadata' => true, 'quoteIdentifiers' => false]);
        Email::configTransport('smtp', ['className' => 'Smtp', 'host' => 'localhost', 'port' => 25, 'timeout' => 30, 'username' => NULL, 'password' => NULL]);
    } 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('Session', array('defaults' => 'php', 'cookie' => 'Template_Admin', 'timeout' => 60));