当前位置: 首页>>代码示例>>PHP>>正文


PHP CakeEmail::getHeaders方法代码示例

本文整理汇总了PHP中CakeEmail::getHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP CakeEmail::getHeaders方法的具体用法?PHP CakeEmail::getHeaders怎么用?PHP CakeEmail::getHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CakeEmail的用法示例。


在下文中一共展示了CakeEmail::getHeaders方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: send

 /**
  * Send mail
  *
  * @params CakeEmail $email
  * @return array
  */
 public function send(CakeEmail $email)
 {
     $post = array();
     $post_preprocess = array_merge($email->getHeaders(array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc', 'subject')), array('text' => $email->message(CakeEmail::MESSAGE_TEXT), 'html' => $email->message(CakeEmail::MESSAGE_HTML)));
     foreach ($post_preprocess as $k => $v) {
         if (!empty($v)) {
             $post[strtolower($k)] = $v;
         }
     }
     $ch = curl_init('https://api.mailgun.net/v2/' . $this->_config['mailgun_domain'] . '/messages');
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_USERPWD, 'api:' . $this->_config['api_key']);
     curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
     $response = curl_exec($ch);
     if ($response === false) {
         throw new SocketException("Curl had an error.  Message: " . curl_error($ch), 500);
     }
     $http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     if ($http_status != 200) {
         throw new SocketException("Mailgun request failed.  Status: {$http_status}, Response: {$response}", 500);
     }
     curl_close($ch);
     return array('headers' => $this->_headersToString($email->getHeaders(), PHP_EOL), 'message' => implode(PHP_EOL, $email->message()));
 }
开发者ID:lorenzomaieru,项目名称:cakephp-mailgun,代码行数:33,代码来源:CurlTransport.php

示例2: send

 /**
  * Sends out email via Mandrill
  *
  * @return array Return the Mandrill
  */
 public function send(CakeEmail $email)
 {
     $this->_Email = $email;
     $this->_config = $this->_Email->config() + (array) Configure::read('Mandrill');
     if (empty($this->_config['apiKey'])) {
         throw new InternalErrorException('No API key');
     }
     if (empty($this->_config['uri'])) {
         $this->_config['uri'] = static::API_URL;
     }
     $include = ['from', 'to', 'cc', 'bcc', 'replyTo', 'subject'];
     $this->_headers = $this->_Email->getHeaders($include);
     $message = $this->_buildMessage();
     $request = ['header' => ['Accept' => 'application/json', 'Content-Type' => 'application/json']];
     $template = $this->_Email->template();
     if ($template['template'] && !empty($this->_config['useTemplate'])) {
         $messageUri = $this->_config['uri'] . "messages/send-template.json";
     } else {
         $messageUri = $this->_config['uri'] . "messages/send.json";
     }
     // Perform the http connection
     $returnMandrill = $this->_post($messageUri, $message, $request);
     // Parse mandrill results
     $result = json_decode($returnMandrill, true);
     if (!empty($this->_config['log'])) {
         CakeLog::write('mandrill', print_r($result, true));
     }
     $headers = $this->_headersToString($this->_headers);
     return array_merge(['Mandrill' => $result], ['headers' => $headers, 'message' => $message]);
 }
开发者ID:drmonkeyninja,项目名称:cakephp-mailchimp,代码行数:35,代码来源:MandrillTransport.php

示例3: send

 /**
  * Sends out email via Mandrill
  *
  * @param CakeEmail $email
  * @return array
  */
 public function send(CakeEmail $email)
 {
     // CakeEmail
     $this->_cakeEmail = $email;
     $from = $this->_cakeEmail->from();
     list($fromEmail) = array_keys($from);
     $fromName = $from[$fromEmail];
     $this->_config = $this->_cakeEmail->config();
     $this->_headers = $this->_cakeEmail->getHeaders();
     $message = array('html' => $this->_cakeEmail->message('html'), 'text' => $this->_cakeEmail->message('text'), 'subject' => mb_decode_mimeheader($this->_cakeEmail->subject()), 'from_email' => $fromEmail, 'from_name' => $fromName, 'to' => array(), 'headers' => array('Reply-To' => $fromEmail), 'important' => false, 'track_opens' => null, 'track_clicks' => null, 'auto_text' => null, 'auto_html' => null, 'inline_css' => null, 'url_strip_qs' => null, 'preserve_recipients' => null, 'view_content_link' => null, 'tracking_domain' => null, 'signing_domain' => null, 'return_path_domain' => null, 'merge' => true, 'tags' => null, 'subaccount' => null);
     $message = array_merge($message, $this->_headers);
     foreach ($this->_cakeEmail->to() as $email => $name) {
         $message['to'][] = array('email' => $email, 'name' => $name, 'type' => 'to');
     }
     foreach ($this->_cakeEmail->cc() as $email => $name) {
         $message['to'][] = array('email' => $email, 'name' => $name, 'type' => 'cc');
     }
     foreach ($this->_cakeEmail->bcc() as $email => $name) {
         $message['to'][] = array('email' => $email, 'name' => $name, 'type' => 'bcc');
     }
     $attachments = $this->_cakeEmail->attachments();
     if (!empty($attachments)) {
         $message['attachments'] = array();
         foreach ($attachments as $file => $data) {
             $message['attachments'][] = array('type' => $data['mimetype'], 'name' => $file, 'content' => base64_encode(file_get_contents($data['file'])));
         }
     }
     $params = array('message' => $message, "async" => false, "ip_pool" => null, "send_at" => null);
     return $this->_exec($params);
 }
开发者ID:surjit,项目名称:Mandrill-CakePHP-plugin,代码行数:36,代码来源:MandrillTransport.php

示例4: send

 /**
  * Sends out email via Mandrill
  *
  * @return array Return the Mandrill
  */
 public function send(CakeEmail $email)
 {
     // CakeEmail
     $this->_cakeEmail = $email;
     $this->_config = $this->_cakeEmail->config();
     $this->_headers = $this->_cakeEmail->getHeaders(array('from', 'to', 'cc', 'bcc', 'replyTo', 'subject'));
     // Setup connection
     $this->__mandrillConnection =& new HttpSocket();
     // Build message
     $message = $this->__buildMessage();
     // Build request
     $request = $this->__buildRequest();
     if (isset($this->_config['mandrillTemplate']) && !empty($this->_config['mandrillTemplate'])) {
         $message_send_uri = $this->_config['uri'] . "messages/send-template.json";
     } else {
         $message_send_uri = $this->_config['uri'] . "messages/send.json";
     }
     // Send message
     try {
         $returnMandrill = $this->__mandrillConnection->post($message_send_uri, json_encode($message), $request);
         // Return data
         $result = json_decode($returnMandrill, true);
         $headers = $this->_headersToString($this->_headers);
         return array_merge(array('Mandrill' => $result), array('headers' => $headers, 'message' => $message));
     } catch (Exception $e) {
         return false;
     }
 }
开发者ID:zooteradmin,项目名称:interview,代码行数:33,代码来源:MandrillTransport.php

示例5: send

 /**
  * Sends out email via SparkPost
  *
  * @param CakeEmail $email
  * @return array
  */
 public function send(CakeEmail $email)
 {
     // CakeEmail
     $this->_cakeEmail = $email;
     $this->_config = $this->_cakeEmail->config();
     $this->_headers = $this->_cakeEmail->getHeaders();
     // Not allowed by SparkPost
     unset($this->_headers['Content-Type']);
     unset($this->_headers['Content-Transfer-Encoding']);
     unset($this->_headers['MIME-Version']);
     unset($this->_headers['X-Mailer']);
     $from = $this->_cakeEmail->from();
     list($fromEmail) = array_keys($from);
     $fromName = $from[$fromEmail];
     $message = ['html' => $this->_cakeEmail->message('html'), 'text' => $this->_cakeEmail->message('text'), 'from' => ['name' => $fromName, 'email' => $fromEmail], 'subject' => mb_decode_mimeheader($this->_cakeEmail->subject()), 'recipients' => [], 'transactional' => true];
     foreach ($this->_cakeEmail->to() as $email => $name) {
         $message['recipients'][] = ['address' => ['email' => $email, 'name' => $name], 'tags' => $this->_headers['tags']];
     }
     foreach ($this->_cakeEmail->cc() as $email => $name) {
         $message['recipients'][] = ['address' => ['email' => $email, 'name' => $name], 'tags' => $this->_headers['tags']];
     }
     foreach ($this->_cakeEmail->bcc() as $email => $name) {
         $message['recipients'][] = ['address' => ['email' => $email, 'name' => $name], 'tags' => $this->_headers['tags']];
     }
     unset($this->_headers['tags']);
     $attachments = $this->_cakeEmail->attachments();
     if (!empty($attachments)) {
         $message['attachments'] = array();
         foreach ($attachments as $file => $data) {
             if (!empty($data['contentId'])) {
                 $message['inlineImages'][] = array('type' => $data['mimetype'], 'name' => $data['contentId'], 'data' => base64_encode(file_get_contents($data['file'])));
             } else {
                 $message['attachments'][] = array('type' => $data['mimetype'], 'name' => $file, 'data' => base64_encode(file_get_contents($data['file'])));
             }
         }
     }
     $message = array_merge($message, $this->_headers);
     // Load SparkPost configuration settings
     $config = ['key' => $this->_config['sparkpost']['api_key']];
     if (isset($this->_config['sparkpost']['timeout'])) {
         $config['timeout'] = $this->_config['sparkpost']['timeout'];
     }
     // Set up HTTP request adapter
     $httpAdapter = new Ivory\HttpAdapter\Guzzle6HttpAdapter($this->__getClient());
     // Create SparkPost API accessor
     $sparkpost = new SparkPost\SparkPost($httpAdapter, $config);
     // Send message
     try {
         return $sparkpost->transmission->send($message);
     } catch (SparkPost\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()));
     }
 }
开发者ID:wvdongen,项目名称:cakephp-sparkpost,代码行数:60,代码来源:SparkPostTransport.php

示例6: send

 /**
  * Sends out email via SendGrid
  *
  * @return bool
  */
 public function send(CakeEmail $email)
 {
     // CakeEmail
     $this->_cakeEmail = $email;
     $this->_config = $this->_cakeEmail->config();
     if (empty($this->_config['count']) || $this->_config['count'] > 500) {
         $this->_config['count'] = 500;
     }
     $this->_headers = $this->_cakeEmail->getHeaders();
     $this->_recipients = $email->to();
     $this->_replyTo = $email->replyTo();
     return $this->_sendPart();
 }
开发者ID:rogerbenevento,项目名称:sendgrid-webapi-cakephp-plugin,代码行数:18,代码来源:SendgridTransport.php

示例7: _prepareData

 /**
  * Prepares the data array.
  *
  * @return void 
  */
 protected function _prepareData()
 {
     $headers = $this->_cakeEmail->getHeaders(array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'subject'));
     if ($headers['Sender'] == '') {
         $headers['Sender'] = $headers['From'];
     }
     $headers = $this->_headersToString($headers);
     $message = implode("\r\n", $this->_cakeEmail->message());
     $this->_data = array('Data' => base64_encode($headers . "\r\n\r\n" . $message . "\r\n\r\n\r\n."));
     $this->_dataOptions = array('Source' => key($this->_cakeEmail->from()), 'Destinations' => array());
     $this->_dataOptions['Destinations'] += array_keys($this->_cakeEmail->to());
     $this->_dataOptions['Destinations'] += array_keys($this->_cakeEmail->cc());
     $this->_dataOptions['Destinations'] += array_keys($this->_cakeEmail->bcc());
     $this->_content = array('headers' => $headers, 'message' => $message);
 }
开发者ID:jellehenkens,项目名称:CakeEmailTransports,代码行数:20,代码来源:AmazonTransport.php

示例8: send

 /**
  * Send mail
  *
  * @param CakeEmail $email CakeEmail
  * @return array
  */
 public function send(CakeEmail $email)
 {
     $headers = $email->getHeaders(array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'subject'));
     $headers = $this->_headersToString($headers);
     $message = implode("\r\n", (array) $email->message());
     return array('headers' => $headers, 'message' => $message);
 }
开发者ID:agashish,项目名称:test_new,代码行数:13,代码来源:DebugTransport.php

示例9: _prepareData

 /**
  * Prepares the data array.
  * Adds headers and content
  *
  * @return void 
  */
 protected function _prepareData()
 {
     $this->_data = array();
     if (count($this->_cakeEmail->cc()) > 0) {
         throw new CakeException('Postageapp transport does not support cc');
     }
     if (count($this->_cakeEmail->bcc()) > 0) {
         throw new CakeException('Postageapp transport does not support bcc');
     }
     if (count($this->_cakeEmail->sender()) > 0) {
         throw new CakeException('Postageapp transport does not support sender');
     }
     $headers = $this->_cakeEmail->getHeaders(array('from', 'sender', 'replyTo', 'returnPath', 'to', 'subject'));
     $this->_data['recipients'] = $headers['To'];
     $map = array('From', 'Subject', 'Reply-To', 'X-Mailer', 'MIME-Version', 'Content-Transfer-Encoding');
     foreach ($map as $header) {
         if (!empty($headers[$header])) {
             $this->_addHeader($header, $headers[$header]);
         }
     }
     $emailFormat = $this->_cakeEmail->emailFormat();
     if ($emailFormat == 'both' || $emailFormat == 'text') {
         $this->_data['content']['text/plain'] = $this->_cakeEmail->message('text');
     }
     if ($emailFormat == 'both' || $emailFormat == 'html') {
         $this->_data['content']['text/html'] = $this->_cakeEmail->message('html');
     }
 }
开发者ID:jellehenkens,项目名称:CakeEmailTransports,代码行数:34,代码来源:PostageappTransport.php

示例10: send

 /**
  * Send email via Mailgun
  *
  * @param CakeEmail $email
  * @return array
  * @throws Exception
  */
 public function send(CakeEmail $email)
 {
     if (Configure::read('Mailgun.preventManyToRecipients') !== false && count($email->to()) > 1) {
         throw new Exception('More than one "to" recipient not allowed (set Mailgun.preventManyToRecipients = false to disable check)');
     }
     $mgClient = new Mailgun($this->_config['mg_api_key']);
     $headersList = array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc', 'subject');
     $params = [];
     foreach ($email->getHeaders($headersList) as $header => $value) {
         if (isset($this->_paramMapping[$header]) && !empty($value)) {
             $key = $this->_paramMapping[$header];
             $params[$key] = $value;
         }
     }
     $params['text'] = $email->message(CakeEmail::MESSAGE_TEXT);
     $params['html'] = $email->message(CakeEmail::MESSAGE_HTML);
     $attachments = array();
     foreach ($email->attachments() as $name => $info) {
         $attachments['attachment'][] = '@' . $info['file'];
     }
     try {
         $result = $mgClient->sendMessage($this->_config['mg_domain'], $params, $attachments);
         if ($result->http_response_code != 200) {
             throw new Exception($result->http_response_body->message);
         }
     } catch (Exception $e) {
         throw $e;
     }
     return $result;
 }
开发者ID:codaxis,项目名称:cakephp-mailgun,代码行数:37,代码来源:MailgunTransport.php

示例11: testPostmarkSend

 /**
  * testPostmarkSend method
  *
  * @return void
  */
 public function testPostmarkSend()
 {
     $this->email->config('postmark');
     $this->email->template('default', 'default');
     $this->email->emailFormat('html');
     $this->email->from(array('yourpostmark@mail.com' => 'Your Name'));
     $this->email->to(array('recipient@domain.com' => 'Recipient'));
     $this->email->cc(array('recipient@domain.com' => 'Recipient'));
     $this->email->bcc(array('recipient@domain.com' => 'Recipient'));
     $this->email->subject('Test Postmark');
     $this->email->addHeaders(array('Tag' => 'my tag'));
     $this->email->attachments(array('cake.icon.png' => array('file' => WWW_ROOT . 'img' . DS . 'cake.icon.png')));
     $sendReturn = $this->email->send();
     $headers = $this->email->getHeaders(array('to'));
     $this->assertEqual($sendReturn['To'], $headers['To']);
     $this->assertEqual($sendReturn['ErrorCode'], 0);
     $this->assertEqual($sendReturn['Message'], 'OK');
 }
开发者ID:julienasp,项目名称:Pilule,代码行数:23,代码来源:PostmarkTransportTest.php

示例12: _sendData

 /**
  * Send Data
  *
  * @return void
  * @throws SocketException
  */
 protected function _sendData()
 {
     $this->_smtpSend('DATA', '354');
     $headers = $this->_cakeEmail->getHeaders(array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'subject'));
     $headers = $this->_headersToString($headers);
     $message = implode("\r\n", $this->_cakeEmail->message());
     $this->_smtpSend($headers . "\r\n\r\n" . $message . "\r\n\r\n\r\n.");
     $this->_content = array('headers' => $headers, 'message' => $message);
 }
开发者ID:gilyaev,项目名称:framework-bench,代码行数:15,代码来源:SmtpTransport.php

示例13: send

 /**
  * Send
  * 
  * A bit of a misnomer, because this actually just adds it to a CakeResque
  * queue.  The actual sending of the email will be performed later by a worker.
  *
  * @params CakeEmail $email
  * @return array
  */
 public function send(CakeEmail $email)
 {
     // Take a copy of the existing configuration.
     $config = array('headers' => $email->getHeaders(), 'from' => $email->from(), 'sender' => $email->sender(), 'replyTo' => $email->replyTo(), 'readReceipt' => $email->readReceipt(), 'returnPath' => $email->returnPath(), 'to' => $email->to(), 'cc' => $email->cc(), 'bcc' => $email->bcc(), 'subject' => $email->subject(), 'viewRender' => $email->viewRender(), 'viewVars' => $email->viewVars(), 'emailFormat' => $email->emailFormat(), 'messageId' => $email->messageId(), 'attachments' => $email->attachments());
     //        unset($config['config']['transport']);
     $template = $email->template();
     $config['template'] = $template['template'];
     $config['layout'] = $template['layout'];
     // Clean it up to avoid errors.
     $config = array_filter($config, function ($v) {
         return (bool) $v;
     });
     debug($config);
     // Include a message, if they sent one via plain text.
     $message = $email->message(CakeEmail::MESSAGE_HTML) ? null : $email->message(CakeEmail::MESSAGE_TEXT);
     // Drop it in a queue.
     Resque::enqueue('email', 'ResqueEmail.EmailShell', array('send', $config, $message));
     return array('headers' => $email->getHeaders(), 'message' => $email->message());
 }
开发者ID:adderall,项目名称:cake-resque-email,代码行数:28,代码来源:QueuedTransport.php

示例14: send

 /**
  * Send
  *
  * @param CakeEmail $email objeto mail
  * @return array
  * @throws SocketException
  */
 public function send(CakeEmail $email)
 {
     $http = new HttpSocket();
     $url = 'https://api.mailgun.net/v2/' . $this->_config['mailgun_domain'] . '/messages';
     $post = array();
     $postPreprocess = array_merge($email->getHeaders(array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc', 'subject')), array('text' => $email->message(CakeEmail::MESSAGE_TEXT), 'html' => $email->message(CakeEmail::MESSAGE_HTML)));
     foreach ($postPreprocess as $k => $v) {
         if (!empty($v)) {
             $post[strtolower($k)] = $v;
         }
     }
     $request = array('auth' => array('method' => 'Basic', 'user' => 'api', 'pass' => $this->_config['api_key']));
     $response = $http->post($url, $post, $request);
     if ($response === false) {
         throw new SocketException("Mailgun BasicTransport error, no response", 500);
     }
     $httpStatus = $response->code;
     if ($httpStatus != 200) {
         throw new SocketException("Mailgun request failed.  Status: {$httpStatus}, Response: {$response->body}", 500);
     }
     return array('headers' => $this->_headersToString($email->getHeaders(), PHP_EOL), 'message' => implode(PHP_EOL, $email->message()));
 }
开发者ID:oxicode,项目名称:cakephp-modo-mantenimiento,代码行数:29,代码来源:BasicTransport.php

示例15: send

 /**
  * Sends out email via Mandrill
  *
  * @param $email
  * @return array Return the Mandrill
  */
 public function send(CakeEmail $email)
 {
     //todo:check restricted_emails
     $this->_cakeEmail = $email;
     $this->_config = $this->_cakeEmail->config();
     $this->_headers = $this->_cakeEmail->getHeaders(array('from', 'to', 'cc', 'bcc', 'replyTo', 'subject'));
     // Setup connection
     $this->__mandrillConnection =& new HttpSocket();
     $message = $this->__buildMessage();
     $request = array('header' => array('Accept' => 'application/json', 'Content-Type' => 'application/json'));
     if ($this->_cakeEmail->template()['template']) {
         $message_send_uri = $this->_config['uri'] . "messages/send-template.json";
     } else {
         $message_send_uri = $this->_config['uri'] . "messages/send.json";
     }
     //perform the http connection
     $returnMandrill = $this->__mandrillConnection->post($message_send_uri, json_encode($message), $request);
     //parse mandrill results
     $result = json_decode($returnMandrill, true);
     $headers = $this->_headersToString($this->_headers);
     return array_merge(array('Mandrill' => $result), array('headers' => $headers, 'message' => $message));
 }
开发者ID:kameshwariv,项目名称:testexample,代码行数:28,代码来源:MandrillTransport.php


注:本文中的CakeEmail::getHeaders方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。