本文整理汇总了PHP中Cake\Mailer\Email::subject方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::subject方法的具体用法?PHP Email::subject怎么用?PHP Email::subject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Mailer\Email
的用法示例。
在下文中一共展示了Email::subject方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setupEmail
protected function setupEmail(Email $email)
{
$this->sendgridEmail = new \SendGrid\Email();
foreach ($email->to() as $e => $n) {
$this->sendgridEmail->addTo($e, $n);
}
foreach ($email->cc() as $e => $n) {
$this->sendgridEmail->addCc($e, $n);
}
foreach ($email->bcc() as $e => $n) {
$this->sendgridEmail->addBcc($e, $n);
}
foreach ($email->from() as $e => $n) {
$this->sendgridEmail->setFrom($e);
$this->sendgridEmail->setFromName($n);
}
$this->sendgridEmail->setSubject($email->subject());
$this->sendgridEmail->setText($email->message(Email::MESSAGE_TEXT));
$this->sendgridEmail->setHtml($email->message(Email::MESSAGE_HTML));
if ($email->attachments()) {
foreach ($email->attachments() as $attachment) {
$this->sendgridEmail->setAttachment($attachment['file'], $attachment['custom_filename']);
}
}
}
示例2: send
public function send(Email $email)
{
$headers = $email->getHeaders(['from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc']);
$to = $headers['To'];
$subject = str_replace(["\r", "\n"], '', $email->subject());
$to = str_replace(["\r", "\n"], '', $to);
$message = implode('\\n', $email->message());
Log::write('debug', 'Mail: to(' . $to . ') subject(' . $subject . ') message(' . $message . ')');
return ['headers' => $headers, 'message' => $message];
}
示例3: 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();
}
示例4: testSendWithEmail
/**
* TestSend method
*
* @return void
*/
public function testSendWithEmail()
{
$config = ['transport' => 'queue', 'charset' => 'utf-8', 'headerCharset' => 'utf-8'];
$this->QueueTransport->config($config);
$Email = new Email($config);
$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->attachments(['wow.txt' => ['data' => 'much wow!', 'mimetype' => 'text/plain', 'contentId' => 'important']]);
$Email->template('test_template', 'test_layout');
$Email->subject("L'utilisateur n'a pas pu être enregistré");
$Email->replyTo('noreply@cakephp.org');
$Email->readReceipt('noreply2@cakephp.org');
$Email->returnPath('noreply3@cakephp.org');
$Email->domain('cakephp.org');
$Email->theme('EuroTheme');
$Email->emailFormat('both');
$Email->set('var1', 1);
$Email->set('var2', 2);
$result = $this->QueueTransport->send($Email);
$this->assertEquals('Email', $result['jobtype']);
$this->assertTrue(strlen($result['data']) < 10000);
$output = unserialize($result['data']);
$emailReconstructed = new Email($config);
foreach ($output['settings'] as $method => $setting) {
call_user_func_array([$emailReconstructed, $method], (array) $setting);
}
$this->assertEquals($emailReconstructed->from(), $Email->from());
$this->assertEquals($emailReconstructed->to(), $Email->to());
$this->assertEquals($emailReconstructed->cc(), $Email->cc());
$this->assertEquals($emailReconstructed->bcc(), $Email->bcc());
$this->assertEquals($emailReconstructed->subject(), $Email->subject());
$this->assertEquals($emailReconstructed->charset(), $Email->charset());
$this->assertEquals($emailReconstructed->headerCharset(), $Email->headerCharset());
$this->assertEquals($emailReconstructed->emailFormat(), $Email->emailFormat());
$this->assertEquals($emailReconstructed->replyTo(), $Email->replyTo());
$this->assertEquals($emailReconstructed->readReceipt(), $Email->readReceipt());
$this->assertEquals($emailReconstructed->returnPath(), $Email->returnPath());
$this->assertEquals($emailReconstructed->messageId(), $Email->messageId());
$this->assertEquals($emailReconstructed->domain(), $Email->domain());
$this->assertEquals($emailReconstructed->theme(), $Email->theme());
$this->assertEquals($emailReconstructed->profile(), $Email->profile());
$this->assertEquals($emailReconstructed->viewVars(), $Email->viewVars());
$this->assertEquals($emailReconstructed->template(), $Email->template());
//for now cannot be done 'data' is base64_encode on set but not decoded when get from $email
//$this->assertEquals($emailReconstructed->attachments(),$Email->attachments());
//debug($output);
//$this->assertEquals($Email, $output['settings']);
}
示例5: send
/**
* Send mail
*
* @param \Cake\Mailer\Email $email Email instance.
* @return array
*/
public function send(Email $email)
{
$this->transportConfig = Hash::merge($this->transportConfig, $this->_config);
$message = ['html' => $email->message(Email::MESSAGE_HTML), 'text' => $email->message(Email::MESSAGE_TEXT), 'subject' => mb_decode_mimeheader($email->subject()), 'from' => key($email->from()), 'fromname' => current($email->from()), 'to' => [], 'toname' => [], 'cc' => [], 'ccname' => [], 'bcc' => [], 'bccname' => [], 'replyto' => array_keys($email->replyTo())[0]];
// Add receipients
foreach (['to', 'cc', 'bcc'] as $type) {
foreach ($email->{$type}() as $mail => $name) {
$message[$type][] = $mail;
$message[$type . 'name'][] = $name;
}
}
// Create a new scoped Http Client
$this->http = new Client(['host' => 'api.sendgrid.com', 'scheme' => 'https', 'headers' => ['User-Agent' => 'CakePHP SendGrid Plugin']]);
$message = $this->_attachments($email, $message);
return $this->_send($message);
}
示例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: sendNewMissionsToInterestedUsers
public function sendNewMissionsToInterestedUsers($nbrDays = 7)
{
$created = Time::now()->subDays($nbrDays);
$missions = $this->Missions->find('all', ['conditions' => ['Missions.created >=' => $created]])->toArray();
$newMissions = [];
foreach ($missions as $mission) {
$users = $this->Users->find('all')->toArray();
foreach ($users as $user) {
$usersTypeMissions = $this->UsersTypeMissions->findByUserId($user['id'])->toArray();
foreach ($usersTypeMissions as $userTypeMissions) {
// Check if the current mission has the same type has the current userType mission
if ($userTypeMissions['type_mission_id'] == $mission['type_mission_id']) {
// Add a new mission to the list of missions to send
if (isset($newMissions[$user['email']])) {
$newMission = [];
$newMission['link'] = Router::url(['controller' => 'Missions', 'action' => 'view', $mission['id']]);
$newMission['name'] = $mission['name'];
//print("Mission " . $newMission['name'] . " added to user " . $user['email'] . "\n");
array_push($newMissions[$user['email']], $newMission);
} else {
//print("Creating mission list for user " . $user['email'] . "\n");
$newMissions[$user['email']] = [];
$newMission = [];
$newMission['link'] = Router::url(['controller' => 'Missions', 'action' => 'view', $mission['id']]);
$newMission['name'] = $mission['name'];
//print("Mission " . $newMission['name'] . " added to user " . $user['email'] . "\n");
array_push($newMissions[$user['email']], $newMission);
}
}
}
}
}
// For each user send their associated list of missions
foreach ($newMissions as $userEmail => $missionsToSend) {
$email = new Email();
$email->domain('maisonlogiciellibre.org');
$email->to($userEmail);
$email->subject('New missions available at ML2');
$email->template('new_missions');
$email->emailFormat('both');
$email->viewVars(['missions' => $missionsToSend]);
$email->send();
}
}
示例8: send
/**
* Send mail
*
* @param \Cake\Mailer\Email $email Cake Email
* @return array
*/
public function send(Email $email)
{
$eol = PHP_EOL;
if (isset($this->_config['eol'])) {
$eol = $this->_config['eol'];
}
$headers = $email->getHeaders(['from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc']);
$to = $headers['To'];
unset($headers['To']);
foreach ($headers as $key => $header) {
$headers[$key] = str_replace(["\r", "\n"], '', $header);
}
$headers = $this->_headersToString($headers, $eol);
$subject = str_replace(["\r", "\n"], '', $email->subject());
$to = str_replace(["\r", "\n"], '', $to);
$message = implode($eol, $email->message());
$params = isset($this->_config['additionalParameters']) ? $this->_config['additionalParameters'] : null;
$this->_mail($to, $subject, $message, $headers, $params);
return ['headers' => $headers, 'message' => $message];
}
示例9: send
/**
* Send notification
*
* @param \CvoTechnologies\Notifier\Notification $notification Notification instance.
* @return array
*/
public function send(Notification $notification)
{
$email = new Email();
$email->profile($this->config('profile'));
$email->to($notification->to(null, static::TYPE));
$email->subject($notification->title());
$email->viewBuilder()->templatePath($notification->viewBuilder()->templatePath());
$email->viewBuilder()->template($notification->viewBuilder()->template());
$email->viewBuilder()->plugin($notification->viewBuilder()->plugin());
$email->viewBuilder()->theme($notification->viewBuilder()->theme());
$email->viewBuilder()->layout($notification->viewBuilder()->layout());
$email->viewBuilder()->autoLayout($notification->viewBuilder()->autoLayout());
$email->viewBuilder()->layoutPath($notification->viewBuilder()->layoutPath());
$email->viewBuilder()->name($notification->viewBuilder()->name());
$email->viewBuilder()->className($notification->viewBuilder()->className());
$email->viewBuilder()->options($notification->viewBuilder()->options());
$email->viewBuilder()->helpers($notification->viewBuilder()->helpers());
$email->viewVars($notification->viewVars());
return $email->send();
}
示例10: send
/**
* Send mail via SparkPost REST API
*
* @param \Cake\Mailer\Email $email Email message
* @return array
*/
public function send(Email $email)
{
// Load SparkPost configuration settings
$apiKey = $this->config('apiKey');
// Set up HTTP request adapter
$adapter = new CakeHttpAdapter(new Client());
// Create SparkPost API accessor
$sparkpost = new SparkPost($adapter, ['key' => $apiKey]);
// Pre-process CakePHP email object fields
$from = (array) $email->from();
$sender = sprintf('%s <%s>', mb_encode_mimeheader(array_values($from)[0]), array_keys($from)[0]);
$to = (array) $email->to();
$recipients = [['address' => ['name' => mb_encode_mimeheader(array_values($to)[0]), 'email' => array_keys($to)[0]]]];
// Build message to send
$message = ['from' => $sender, 'html' => empty($email->message('html')) ? $email->message('text') : $email->message('html'), 'text' => $email->message('text'), 'subject' => mb_decode_mimeheader($email->subject()), 'recipients' => $recipients];
// Send message
try {
$sparkpost->transmission->send($message);
} catch (APIResponseException $e) {
// TODO: Determine if BRE is the best exception type
throw new BadRequestException(sprintf('SparkPost API error %d (%d): %s (%s)', $e->getAPICode(), $e->getCode(), ucfirst($e->getAPIMessage()), $e->getAPIDescription()));
}
}
示例11: _getEmailByNewStyleCharset
/**
* @param mixed $charset
* @param mixed $headerCharset
* @return \Cake\Mailer\Email
*/
protected function _getEmailByNewStyleCharset($charset, $headerCharset)
{
$email = new Email(['transport' => 'debug']);
if (!empty($charset)) {
$email->charset($charset);
}
if (!empty($headerCharset)) {
$email->headerCharset($headerCharset);
}
$email->from('someone@example.com', 'どこかの誰か');
$email->to('someperson@example.jp', 'どこかのどなたか');
$email->cc('miku@example.net', 'ミク');
$email->subject('テストメール');
$email->send('テストメールの本文');
return $email;
}
示例12: sendmail
/**
* sendmail method
* Send Email using postmark addon
* @param string|null $id Word id.
* @return void
* @throws \Cake\Network\Exception\NotFoundException When record not found.
*/
public function sendmail($email, $subject, $mailText)
{
$mail = "mail";
$loginuser = $this->Auth->user();
$data = [];
$data = ['mailFrom' => 'cchoi1803@conestogac.on.ca', 'email' => $email, 'mailSubject' => $subject, 'mailText' => $mailText];
$email = new Email('default');
$email->from(['cchoi1803@conestogac.on.ca' => 'Word Master']);
$email->to($data['email']);
$email->subject($data['mailSubject']);
$email->send($data['mailText']);
$this->set('result', $data);
}
示例13: send
/**
* Send emails
*
* @param string $template
* @param array $data
* @param string $config
* @throws SocketException if mail could not be sent
*/
public function send($data = [], $template = 'default', $config = 'default')
{
// initialize class
$email = new Email($config);
// to?
if (isset($data['to'])) {
$email->to($data['to']);
}
// brand
$from = $email->from();
$brand = reset($from);
// subject?
$subject = isset($data['subject']) ? $data['subject'] : $email->subject();
$email->subject(trim($config == 'debug' ? $brand . ' report: ' . $subject : $subject . ' - ' . $brand));
// template?
$email->template($template);
// data & send
$email->viewVars(['subject' => $subject, 'form' => isset($data['form']) ? $data['form'] : [], 'brand' => $brand, 'info' => ['ip' => $this->request->clientIP(), 'useragent' => env('HTTP_USER_AGENT'), 'date' => strftime('%d.%m.%Y %H:%M')]])->send();
}
示例14: submitcontactform
public function submitcontactform()
{
$this->loadModel('Contacts');
if ($this->request->is('post')) {
$email = $this->request->data['email'];
$contactData = [];
$contactTable = TableRegistry::get('Contacts');
$contactData = $contactTable->find()->where(['email' => $email])->first();
if (empty($contactData)) {
$contactTable = TableRegistry::get('Contacts');
$saveData = $contactTable->newEntity($this->request->data);
if ($contactTable->save($saveData)) {
$email = new Email('default');
$data = 'Name: ' . $this->request->data['name'] . ', Email: ' . $this->request->data['email'] . ', City:' . $this->request->data['city'];
$email->subject('Do not see your city?')->to('contact@terra-app.com')->from($this->request->data['email'])->send($data);
$data = '<div class="showSuccess">Thanks for submitting the form. We will contact you soon.</div>';
echo json_encode(array('response' => 1, 'data' => $data));
}
} else {
$data = '<div class="showError">Email is already exist. Please use another email.</div>';
echo json_encode(array('response' => 0, 'data' => $data));
}
}
exit;
}