當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。