本文整理汇总了PHP中Cake\Mailer\Email::configTransport方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::configTransport方法的具体用法?PHP Email::configTransport怎么用?PHP Email::configTransport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Mailer\Email
的用法示例。
在下文中一共展示了Email::configTransport方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _execute
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(['me@example.com' => 'My Site'])->to('zach@crystalclearfiber.com')->subject('About')->send('My message');
return true;
}
示例2: setUp
/**
* 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: setUp
/**
* 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' => 'test@example.com', 'transport' => 'test']);
}
示例4: setUp
/**
* 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' => 'test@example.com', 'transport' => 'test', 'template' => 'CakeDC/Users.social_account_validation']);
}
示例5: testSend
public function testSend()
{
Email::configTransport('default', ['className' => 'Debug']);
Email::config('default', ['from' => 'email@example.com', 'transport' => 'default']);
Configure::write('App.encoding', 'UTF-8');
$notification = new Notification();
$notification->to('destination@example.com', 'email');
$emailTransport = new EmailTransport();
$this->assertInternalType('array', $emailTransport->send($notification));
}
示例6: setUp
/**
* 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' => 'cakedc@example.com']);
$this->Email = new Email(['from' => 'test@example.com', 'transport' => 'test']);
Plugin::routes('CakeDC/Users');
}
示例7: setUp
/**
* 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' => 'cakedc@example.com']);
$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: setUp
/**
* 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' => 'cakedc@example.com']);
}
}
示例9: putenv
$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: testMockTransport
/**
* CakeEmailTest::testMockTransport()
*/
public function testMockTransport()
{
$mock = $this->getMockBuilder('\\Cake\\Mailer\\AbstractTransport')->getMock();
$config = ['from' => 'tester@example.org', 'transport' => 'default'];
Email::config('default', $config);
Email::configTransport('default', $mock);
$em = new Email('default');
$this->assertSame($mock, $em->transport());
}
示例11: read
<?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: function
<?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' => 'foo@bar.com']]);
示例13: testSendResetPasswordEmail
/**
* 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' => 'test@example.com', 'transport' => 'test', 'template' => 'CakeDC/Users.reset_password', 'emailFormat' => 'both']);
$user = $this->table->newEntity(['first_name' => 'FirstName', 'email' => 'test@example.com', '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');
}
示例14: setUp
public function setUp()
{
Email::configTransport('default', ['className' => 'Debug']);
}
示例15: array
}
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' => 'tien@bliss-interactive.com', '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));