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


PHP Email::attachments方法代码示例

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


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

示例1: sendNotification

 /**
  * Abstract sender method
  *
  * @param User $user The recipient user
  * @param Notification $notification the notification to be sent
  * @param NotificationContent $content the content
  * @return mixed
  */
 public function sendNotification(User $user, Notification $notification, NotificationContent $content)
 {
     $subject = $content->render('email_subject', $notification);
     $htmlBody = $content->render('email_html', $notification);
     $textBody = $content->render('email_text', $notification);
     $email = new Email($this->_config['profile']);
     $email->transport($this->_config['emailTransport']);
     $email->emailFormat('html');
     if (!empty($notification->config['attachments'])) {
         $email->attachments($notification->config['attachments']);
     }
     $email->to([$user->email => $user->firstname . ' ' . $user->lastname]);
     $email->subject($subject);
     if (!empty($this->_config['templated']) && !empty($this->_config['template']) && !empty($this->_config['layout'])) {
         $email->template($this->_config['template'], $this->_config['layout']);
         $email->viewVars(['content' => $htmlBody]);
         return $email->send();
     }
     return $email->send($htmlBody);
 }
开发者ID:kiliansch,项目名称:cake-notifications,代码行数:28,代码来源:EmailTransport.php

示例2: _attachments

 /**
  * Format the attachments
  *
  * @param Email $email
  * @param type $message
  * @return array Message
  */
 protected function _attachments(Email $email, $message = [])
 {
     foreach ($email->attachments() as $filename => $attach) {
         $content = base64_encode(file_get_contents($attach['file']));
         if (isset($attach['contentId'])) {
             $message['images'][] = ['type' => $attach['mimetype'], 'name' => $attach['contentId'], 'content' => $content];
         } else {
             $message['attachments'][] = ['type' => $attach['mimetype'], 'name' => $filename, 'content' => $content];
         }
     }
     return $message;
 }
开发者ID:lennaert,项目名称:cakephp3-mandrill,代码行数:19,代码来源:MandrillTransport.php


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