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


PHP Swift_Message::setData方法代码示例

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


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

示例1:

 /**
  * FUNCTION: _sendMail
  *
  * Proccesses all headers and attachments ready for sending.
  *
  * @access private
  */
 function _sendMail()
 {
     $message = new Swift_Message($this->subject);
     if (empty($this->sendto) and (empty($this->body) and empty($this->htmlbody))) {
         vlibMimeMailError::raiseError('VM_ERROR_CANNOT_SEND', FATAL);
     }
     // Attachments
     for ($index = 0; $index < sizeof($this->attachments); $index++) {
         $message->attach(new Swift_Message_Attachment(new Swift_File($this->attachments[$index]), $this->attachments[$index], $this->mimetypes[$index]));
     }
     // ReplyTo if exists
     if (!empty($this->replyToEmail)) {
         $message->setReplyTo(new Swift_Address($this->replyToEmail, $this->replyToName));
     }
     // attach body if exist
     if (!empty($this->body)) {
         if (empty($this->htmlbody) and sizeof($this->attachments) == 0) {
             $message->setData($this->body);
             Swift_ClassLoader::load('Swift_Message_Encoder');
             if (Swift_Message_Encoder::instance()->isUTF8($this->body)) {
                 $message->setCharset('utf-8');
             } else {
                 $message->setCharset('iso-8859-1');
             }
         } else {
             $message->attach(new Swift_Message_Part($this->body, 'text/plain'));
         }
     }
     // attach HTML body if exist
     if (!empty($this->htmlbody)) {
         $message->attach(new Swift_Message_Part($this->htmlbody, 'text/html'));
     }
     return $this->swift->send($message, $this->swift_recipients, new Swift_Address($this->fromEmail, $this->fromName));
 }
开发者ID:ThYpHo0n,项目名称:torrentflux,代码行数:41,代码来源:vlibMimeMail.php

示例2: backup_module_log_error

/**
 * Send error log to administrator
 *
 * @param array $errors
 * @return boolean
 */
function backup_module_log_error($errors, $send_email = false)
{
    $log_message = is_foreachable($errors) ? implode("\n", $errors) : $errors;
    if ($send_email) {
        $mailer =& ApplicationMailer::mailer();
        $recipient = new Swift_Address();
        $recipient->setAddress(ADMIN_EMAIL);
        $recipient->setName('activeCollab admin');
        $sender = new Swift_Address();
        $sender->setAddress(ConfigOptions::getValue('notifications_from_email'));
        $sender->setName(ConfigOptions::getValue('notifications_from_name'));
        $tmp_message = "Automatic backup of activeCollab on " . ROOT_URL . " failed.\n\r";
        $tmp_message .= "Backup returned these errors: \n\r\n\r";
        $tmp_message .= $log_message;
        $message = new Swift_Message();
        $message->setSubject('activeCollab automatic backup error log');
        $message->setData($tmp_message);
        $message->setContentType('text/plain');
        $mailer->send($message, $recipient, $sender);
    }
    // if
    log_message($log_message, LOG_LEVEL_ERROR, 'backup');
}
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:29,代码来源:init.php


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