本文整理汇总了PHP中Cake\Mailer\Email::config方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::config方法的具体用法?PHP Email::config怎么用?PHP Email::config使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Mailer\Email
的用法示例。
在下文中一共展示了Email::config方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
/**
* tearDown method
*
* @return void
*/
public function tearDown()
{
unset($this->Users);
Router::fullBaseUrl($this->fullBaseBackup);
Email::drop('default');
Email::dropTransport('test');
Email::config('default', $this->configEmail);
parent::tearDown();
}
示例2: tearDown
/**
* tearDown
*
* @return void
*/
public function tearDown()
{
Email::drop('default');
Email::dropTransport('test');
Email::config('default', $this->configEmail);
Configure::write('Opauth', $this->configOpauth);
Configure::write('Users.RememberMe.active', $this->configRememberMe);
parent::tearDown();
}
示例3: testConfig
/**
* Test configuration
*
* @return void
*/
public function testConfig()
{
$Email = new Email();
$Email->transport('queue');
$Email->config('default');
$res = $Email->transport()->config();
//debug($res);
//$this->assertTrue(isset($res['queue']));
}
示例4: tearDown
/**
* tearDown
*
* @return void
*/
public function tearDown()
{
unset($this->table, $this->Trait);
if ($this->mockDefaultEmail) {
Email::drop('default');
Email::dropTransport('test');
Email::config('default', $this->configEmail);
}
parent::tearDown();
}
示例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: send
/**
* Send mail
*
* @param Email $email Email
* @return array
*/
public function send(Email $email)
{
if (!empty($this->_config['queue'])) {
$this->_config = $this->_config['queue'] + $this->_config;
$email->config((array) $this->_config['queue'] + ['queue' => []]);
unset($this->_config['queue']);
}
$transport = $this->_config['transport'];
$email->transport($transport);
$QueuedTasks = TableRegistry::get('Queue.QueuedTasks');
$result = $QueuedTasks->createJob('Email', ['transport' => $transport, 'settings' => $email]);
$result['headers'] = '';
$result['message'] = '';
return $result;
}
示例7: testSendWithEmail
/**
* TestSend method
*
* @return void
*/
public function testSendWithEmail()
{
$Email = new Email();
$Email->from('noreply@cakephp.org', 'CakePHP Test');
$Email->to('cake@cakephp.org', 'CakePHP');
$Email->cc(['mark@cakephp.org' => 'Mark Story', 'juan@cakephp.org' => 'Juan Basso']);
$Email->bcc('phpnut@cakephp.org');
$Email->subject('Testing Message');
$Email->transport('queue');
$config = $Email->config('default');
$this->QueueTransport->config($config);
$result = $this->QueueTransport->send($Email);
$this->assertEquals('Email', $result['job_type']);
$this->assertTrue(strlen($result['data']) < 10000);
$output = json_decode($result['data'], true);
$this->assertEquals('Testing Message', $output['settings']['_subject']);
}
示例8: send
/**
* Send mail
*
* @param \Cake\Mailer\Email $email Email
* @return array
*/
public function send(Email $email)
{
if (!empty($this->_config['queue'])) {
$this->_config = $this->_config['queue'] + $this->_config;
$email->config((array) $this->_config['queue'] + ['queue' => []]);
unset($this->_config['queue']);
}
$settings = ['from' => [$email->from()], 'to' => [$email->to()], 'cc' => [$email->cc()], 'bcc' => [$email->bcc()], 'charset' => [$email->charset()], 'replyTo' => [$email->replyTo()], 'readReceipt' => [$email->readReceipt()], 'returnPath' => [$email->returnPath()], 'messageId' => [$email->messageId()], 'domain' => [$email->domain()], 'getHeaders' => [$email->getHeaders()], 'headerCharset' => [$email->headerCharset()], 'theme' => [$email->theme()], 'profile' => [$email->profile()], 'emailFormat' => [$email->emailFormat()], 'subject' => method_exists($email, 'getOriginalSubject') ? [$email->getOriginalSubject()] : [$email->subject()], 'transport' => [$this->_config['transport']], 'attachments' => [$email->attachments()], 'template' => $email->template(), 'viewVars' => [$email->viewVars()]];
foreach ($settings as $setting => $value) {
if (array_key_exists(0, $value) && ($value[0] === null || $value[0] === [])) {
unset($settings[$setting]);
}
}
$QueuedJobs = $this->getQueuedJobsModel();
$result = $QueuedJobs->createJob('Email', ['settings' => $settings]);
$result['headers'] = '';
$result['message'] = '';
return $result;
}
示例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']]);