本文整理汇总了PHP中Cake\Mailer\Email::transport方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::transport方法的具体用法?PHP Email::transport怎么用?PHP Email::transport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Mailer\Email
的用法示例。
在下文中一共展示了Email::transport方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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']));
}
示例2: preview
public function preview($e)
{
$configName = $e['config'];
$template = $e['template'];
$layout = $e['layout'];
$headers = empty($e['headers']) ? [] : (array) $e['headers'];
$theme = empty($e['theme']) ? '' : (string) $e['theme'];
$email = new Email($configName);
if (!empty($e['attachments'])) {
$email->attachments($e['attachments']);
}
$email->transport('Debug')->to($e['email'])->subject($e['subject'])->template($template, $layout)->emailFormat($e['format'])->addHeaders($headers)->theme($theme)->messageId(false)->returnPath($email->from())->viewVars($e['template_vars']);
$return = $email->send();
$this->out('Content:');
$this->hr();
$this->out($return['message']);
$this->hr();
$this->out('Headers:');
$this->hr();
$this->out($return['headers']);
$this->hr();
$this->out('Data:');
$this->hr();
debug($e['template_vars']);
$this->hr();
$this->out();
}
示例3: testMissingRequiredFields
/**
* Test required fields
*
* @return void
*/
public function testMissingRequiredFields()
{
$this->setExpectedException('BadMethodCallException');
$this->SparkPostTransport->config($this->validConfig);
$email = new Email();
$email->transport($this->SparkPostTransport);
$email->to('test@sparkpostbox.com')->subject('This is test subject')->emailFormat('text')->send('Testing Maingun');
}
示例4: mailer
/**
* mailer method
*
* @param array $data Dados para formar o email.
* @return boolean True ou False.
*/
public function mailer($data, $template, $subject)
{
$email = new Email();
$email->transport('mailSgl');
$email->emailFormat('html');
$email->template($template);
$email->from('sglmailer@gmail.com', 'SGL');
$email->to($data['email'], $data['nome']);
$email->viewVars($data);
$email->subject($subject);
$email->send();
}
示例5: 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;
}
示例6: 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']);
}
示例7: add
/**
* Add method
*
* @return mixed Redirects on successful add, renders view otherwise.
*/
public function add()
{
$estate = $this->Estates->newEntity();
if ($this->request->is('post')) {
$estate = $this->Estates->patchEntity($estate, $this->request->data);
if ($this->Estates->save($estate)) {
$this->Flash->success(__('The estate has been saved.'));
$email = new Email();
$email->transport('default');
$email->from(['develop996bn@yahoo.co.jp' => 'My Site'])->to('uedatakeshi@gmail.com')->subject('About')->send('My message');
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The estate could not be saved. Please, try again.'));
}
}
$this->set(compact('estate'));
$this->set('_serialize', ['estate']);
}
示例8: sendMail
public function sendMail()
{
$this->autoRender = FALSE;
$data = $this->request->data;
$from = ['hr@vibeosys.com' => $data['fname'] . ' ' . $data['lname']];
$to = 'anand@vibeosys.com';
$subject = "QuickServe sales inquiry";
$content = "";
$content .= "<table style='height: 100%; margin-left: auto; margin-right: auto;' width='677'><tbody>" . "<tr><td colspan='2'><h1 style='text-align: center;'><span style='color: #ff0000;'><strong>Sales Inquiry</strong></span></h1></td></tr>" . "<tr><td style='text-align: justify;' width='30px'><h2 style='padding-left: 30px;'><strong>Name:</strong></h2></td>" . "<td> <span style='font-size: 12pt;'>" . $data['fname'] . " " . $data['lname'] . "</span></td></tr>" . "<tr><td style='text-align: justify;'><h2 style='padding-left: 30px;'><strong>Email:</strong></h2></td>" . "<td><span style='font-size: 12pt;'> " . $data['email'] . "</span></td></tr>" . "<tr><td style='text-align: justify;'><h2 style='padding-left: 30px;'><strong>Phone:</strong></h2></td>" . "<td> <span style='font-size: 12pt;'>" . $data['phone'] . "</span></td></tr>" . "<tr><td style='text-align: justify;'><h2 style='text-align: justify; padding-left: 30px;'><strong>Restaurant:</strong></h2></td>" . "<td><span style='font-size: 12pt;'> " . $data['restaurant'] . "</span></td></tr>" . "<tr><td style='text-align: justify;'><h2 style='text-align: justify; padding-left: 30px;'><strong>Comment</strong></h2></td>" . "<td style='word-break: break-all;'><p style='text-align: justify;'><span style='font-size: 12pt;'>" . $data['msg'] . "</span></p></td></tr>" . "</tbody></table>";
try {
$mailer = new Email();
$mailer->transport('quickserve');
$mailer->template('', 'default');
$headers = ['Content-Type:text/HTML'];
$result = $mailer->from($from)->emailFormat('html')->to($to)->template('default')->subject($subject)->send($content);
if ($result) {
$this->response->body(true);
} else {
$this->response->body(false);
}
} catch (Exception $e) {
$this->response->body(false);
}
}
示例9: 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());
}
示例10: _confirmEmail
/**
* Sends the user an email to confirm that the correct address has been entered
*
**/
private function _confirmEmail($user, $emailId)
{
// Generate a hash
$hash = Security::hash(date('Y-m-Y-i-s') . $user['username'] . $_SERVER['REMOTE_ADDR']);
// Save hash and reset time to user's record
$save = $this->Users->get($user['id']);
$save->reset_hash = $hash;
$save->reset_time = date('Y-m-d H:i:s');
$this->Users->save($save);
// Email a link including the hash to the user
$to = $this->request->data['email'];
$message = 'Please click on this link to confirm your email address and activate your account:' . PHP_EOL . PHP_EOL . 'http://' . $_SERVER['HTTP_HOST'] . '/users/checkEmail/' . $hash . '/' . $user['id'] . '/' . $emailId . PHP_EOL . PHP_EOL . ' -Vooderbot';
$email = new Email('default');
$email->transport('mailjet')->from(['vooderbot@vooders.com' => 'Vooders.com'])->to($to)->subject('Confirm your email address')->send($message);
// Set flash and redirect
$this->Flash->success(__('Thank you - we have sent you a link to confirm your email address.'));
}
示例11: forgot
/**
* Allow a user to request a password reset.
* @return
*/
function forgot()
{
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
$userInfo = TableRegistry::get('Users');
$userDetails = TableRegistry::get('UserDetails');
//print_r($_REQUEST);die();
if ($this->request->query) {
$user_email = $_REQUEST['email'];
if (!empty($user_email)) {
$users = $userInfo->find('all', ['conditions' => ['Users.email' => $user_email]]);
$user = $users->first();
$user_details = $userDetails->find('all', ['conditions' => ['UserDetails.user_id' => $user->id]]);
$userInfo = $user_details->first();
//echo $user->email;die;
if (!$user) {
$mesg['msg'] = 'Sorry, the username entered was not found.';
$mesg['response_code'] = '0';
echo json_encode($mesg);
die;
} else {
//Time::$defaultLocale = 'es-ES';
$link = BASE_SERVER_URL . 'logins/forgotpassform';
$time = Time::now('Asia/Kolkata');
$time_new = $time->i18nFormat('yyyy-MM-dd HH:mm:ss');
$token = $user->id . "+" . $user->email . "+" . $time_new;
$token_new = base64_encode($token);
//$email = new Email('mailjet');
$email = new Email();
$email->transport('mailjet');
$email->viewVars(['last_name' => $userInfo->lastname]);
$email->viewVars(['PASSWORD_RESET_LINK' => FORGOT_PAGE_LINK]);
$email->from(['himani.arora@sdnainfotech.com' => 'My Site'])->template('forgot', 'htmlemail')->emailFormat('html')->to($user->email)->subject('Forgot Password')->send();
if ($email) {
$mesg['msg'] = 'Mail send to your mail. Please check inbox.';
$mesg['response_code'] = '1';
echo json_encode($mesg);
die;
}
}
}
}
}
示例12: register
//.........这里部分代码省略.........
die;
}
if (!preg_match('/^[a-z0-9A-Z]*$/', $password)) {
$mesg['msg'] = 'The password that you have given is not valid.It should be alphanumeric.Please try again.';
$mesg['response_code'] = '0';
echo json_encode($mesg);
die;
}
if (strlen($password) < 6) {
$mesg['msg'] = 'Minimum 6 characters required for password.';
$mesg['response_code'] = '0';
echo json_encode($mesg);
die;
}
if (!ctype_digit($telephoneno)) {
$mesg['msg'] = 'Given telephone number is not a numeric.';
$mesg['response_code'] = '0';
echo json_encode($mesg);
die;
}
if (strlen($telephoneno) > 20) {
$mesg['msg'] = 'Maximum 20 characters can be used for telephone no.';
$mesg['response_code'] = '0';
echo json_encode($mesg);
die;
}
if (!empty($fax_no)) {
if (!ctype_digit($fax_no)) {
$mesg['msg'] = 'Given fax number is not a numeric.';
$mesg['response_code'] = '0';
echo json_encode($mesg);
die;
}
if (strlen($fax_no) > 20) {
$mesg['msg'] = 'Maximum 20 characters can be used for fax no.';
$mesg['response_code'] = '0';
echo json_encode($mesg);
die;
}
}
$user = $this->Users->newEntity();
$getArray = array('email' => $email, 'password' => $password, 'status' => '1');
$user = $this->Users->patchEntity($user, $getArray);
$query = $this->Users->find('all', ['conditions' => ['Users.email LIKE ' => '%' . $search . '%'], 'limit' => 1])->all();
$counts = $query->count();
if ($counts == '1') {
//DUPLICATE MAIL CHECK
$mesg['msg'] = 'The email already in use. Please, try again.';
$mesg['response_code'] = '0';
echo json_encode($mesg);
die;
}
if ($this->Users->save($user)) {
//print_r($user->id);
$userAddress = TableRegistry::get('UserAddresses');
$UserDetails = TableRegistry::get('UserDetails');
$user_address = $userAddress->newEntity();
$user_address->user_id = $user->id;
$user_address->street_address = $street;
//$user_address->country = $country;
$user_address->country = 'Singapore';
$user_address->postalcode = $postalcode;
$user_address->telephone = $telephoneno;
$user_address->fax_no = $fax_no;
if ($userAddress->save($user_address)) {
$userAddress_lastid = $user_address->id;
}
$User_details = $UserDetails->newEntity();
$User_details->user_id = $user->id;
$User_details->firstname = $fname;
$User_details->lastname = $lname;
$User_details->blockno = $blockno;
$User_details->unitno = $unitno;
$User_details->company = $compname;
$User_details->position = $position;
if ($UserDetails->save($User_details)) {
//$User_details_lastid = $UserDetails->getLastInsertID();
}
//SEND EMAIL...............................
//http://book.cakephp.org/3.0/en/core-libraries/email.html
$emailer = new Email();
$emailer->transport('mailjet');
$emailer->viewVars(['last_name' => $lname]);
//$emailto='deepak.rathi@sdnainfotech.com';
$emailto = $email;
try {
$res = $emailer->from(['bls@admin.com'])->template('welcome', 'fancy')->emailFormat('html')->to([$emailto => 'BLS-New User'])->subject('Membership activation')->send('test-email...');
} catch (Exception $e) {
echo 'Exception : ', $e->getMessage(), "\n";
}
//----------------------------------------
$mesg['msg'] = 'The user has been saved.';
$mesg['response_code'] = '1';
} else {
$mesg['msg'] = 'The user could not be saved. Please, try again.';
$mesg['response_code'] = '0';
}
echo json_encode($mesg);
die;
}
示例13: testAdditionalHeaders
/**
* Test additional headers
*
* @return void
*/
public function testAdditionalHeaders()
{
$this->MailgunTransport->config($this->validConfig);
$email = new Email();
$email->transport($this->MailgunTransport);
$result = $email->from('sender@test.mailgun.org')->to('test@test.mailgun.org')->subject('This is test subject')->addHeaders(['o:tag' => 'testing', 'o:tracking' => 'yes'])->addHeaders(['v:custom-data' => json_encode(['foo' => 'bar'])])->send('Testing Maingun');
$this->assertEquals("test.mailgun.org/messages", $result->http_endpoint_url);
}