當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Swift_ClassLoader類代碼示例

本文整理匯總了PHP中Swift_ClassLoader的典型用法代碼示例。如果您正苦於以下問題:PHP Swift_ClassLoader類的具體用法?PHP Swift_ClassLoader怎麽用?PHP Swift_ClassLoader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Swift_ClassLoader類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: send

 public function send()
 {
     //load swift class.
     require_once CLASSES_DIR . "Swift.php";
     Swift_ClassLoader::load("Swift_Connection_SMTP");
     // Create the message, and set the message subject.
     $message =& new Swift_Message($this->get('subject'));
     //create the html / text body
     $message->attach(new Swift_Message_Part($this->get('html_body'), "text/html"));
     $message->attach(new Swift_Message_Part($this->get('text_body'), "text/plain"));
     // Set the from address/name.
     $from =& new Swift_Address(EMAIL_USERNAME, EMAIL_NAME);
     // Create the recipient list.
     $recipients =& new Swift_RecipientList();
     // Add the recipient
     $recipients->addTo($this->get('to_email'), $this->get('to_name'));
     //connect and create mailer
     $smtp =& new Swift_Connection_SMTP("smtp.gmail.com", Swift_Connection_SMTP::PORT_SECURE, Swift_Connection_SMTP::ENC_TLS);
     $smtp->setUsername(EMAIL_USERNAME);
     $smtp->setPassword(EMAIL_PASSWORD);
     $mailer = new Swift($smtp);
     // Attempt to send the email.
     try {
         $result = $mailer->send($message, $recipients, $from);
         $mailer->disconnect();
         $this->set('status', 'sent');
         $this->set('sent_date', date("Y-m-d H:i:s"));
         $this->save();
         return true;
     } catch (Swift_BadResponseException $e) {
         return $e->getMessage();
     }
 }
開發者ID:ricberw,項目名稱:BotQueue,代碼行數:33,代碼來源:email.php

示例2:

 /**
  * Return a new instance of the cache object
  * @return Swift_Cache
  */
 function &getCache()
 {
     $className = $GLOBALS["_SWIFT_CACHE_CLASS_"];
     Swift_ClassLoader::load($className);
     $instance =& new $className();
     return $instance;
 }
開發者ID:jeffthestampede,項目名稱:excelsior,代碼行數:11,代碼來源:CacheFactory.php

示例3: getCache

 /**
  * Return a new instance of the cache object
  * @return Swift_Cache
  */
 public static function getCache()
 {
     $className = self::$className;
     Swift_ClassLoader::load($className);
     $instance = new $className();
     return $instance;
 }
開發者ID:dev-lav,項目名稱:htdocs,代碼行數:11,代碼來源:CacheFactory.php

示例4: write

 /**
  * Write data to the cache
  * @param string The cache key
  * @param string The data to write
  */
 public function write($key, $data)
 {
     $handle = fopen(self::$save_path . "/" . $this->prefix . $key, "ab");
     if (false === fwrite($handle, $data)) {
         Swift_ClassLoader::load("Swift_FileException");
         throw new Swift_FileException("Disk Caching failed.  Tried to write to file at [" . self::$save_path . "/" . $this->prefix . $key . "] but failed.  Check the permissions, or don't use disk caching.");
     }
     fclose($handle);
 }
開發者ID:kjgarza,項目名稱:ushahidi,代碼行數:14,代碼來源:Disk.php

示例5: __construct

 /**
  * Constructor
  * @param mixed Swift_Authenticator_PopB4Smtp_Pop3Connection or string FQDN of POP3 server
  * @param int The remote port number
  * @param int The level of encryption to use
  */
 public function __construct($conn=null, $port=110, $encryption=0)
 {
   if (is_object($conn)) $this->connection = $conn;
   else
   {
     Swift_ClassLoader::load("Swift_Authenticator_PopB4Smtp_Pop3Connection");
     $this->connection = new Swift_Authenticator_PopB4Smtp_Pop3Connection($conn, $port, $encryption);
   }
 }
開發者ID:neutrinog,項目名稱:Door43,代碼行數:15,代碼來源:PopB4Smtp.php

示例6: Swift_Authenticator_PopB4Smtp

 /**
  * Constructor
  * @param mixed Swift_Authenticator_PopB4Smtp_Pop3Connection or string FQDN of POP3 server
  * @param int The remote port number
  * @param int The level of encryption to use
  */
 function Swift_Authenticator_PopB4Smtp($conn = null, $port = 110, $encryption = 0)
 {
     if (is_object($conn)) {
         $this->connection =& $conn;
     } else {
         Swift_ClassLoader::load("Swift_Authenticator_PopB4Smtp_Pop3Connection");
         $this->connection =& new Swift_Authenticator_PopB4Smtp_Pop3Connection($conn, $port, $encryption);
     }
 }
開發者ID:jeffthestampede,項目名稱:excelsior,代碼行數:15,代碼來源:PopB4Smtp.php

示例7: write

 /**
  * Write data to the cache
  * @param string The cache key
  * @param string The data to write
  */
 function write($key, $data)
 {
     $handle = @fopen($GLOBALS["_SWIFT_FILECACHE_SAVE_PATH_"] . "/" . $this->prefix . $key, "ab");
     if (false === $handle || false === fwrite($handle, $data)) {
         Swift_ClassLoader::load("Swift_FileException");
         Swift_ClassLoader::load("Swift_Errors");
         Swift_Errors::trigger(new Swift_FileException("Disk Caching failed.  Tried to write to file at [" . $GLOBALS["_SWIFT_FILECACHE_SAVE_PATH_"] . "/" . $this->prefix . $key . "] but failed.  Check the permissions, or don't use disk caching."));
         return;
     }
     fclose($handle);
 }
開發者ID:jeffthestampede,項目名稱:excelsior,代碼行數:16,代碼來源:Disk.php

示例8: send_mail

 /**
  * 郵件發送
  * @return boolean
  */
 public function send_mail($recipient, $mailsubject, $mailbody)
 {
     apf_require_file("Swift.php");
     Swift_ClassLoader::load("Swift_Connection_SMTP");
     $message = new Swift_Message($mailsubject);
     $message->setFrom("安居客<noreply@dm.anjuke.com>");
     $message->attach(new Swift_Message_Part(strip_tags($mailbody), "text/plain", "base64", "utf-8"));
     $message->attach(new Swift_Message_Part($mailbody, "text/html", "base64", "utf-8"));
     foreach ($recipient as $re) {
         Mail_Queue::put('noreply@dm.anjuke.com', $re, $mailsubject, $message, Const_Mail::TYPE_SWIFT, Const_Mail::TYPE_ID_COMMUNITY_SUBSCRIBE);
     }
     return true;
 }
開發者ID:emilymwang8,項目名稱:ajk-broker,代碼行數:17,代碼來源:CheckPrize.php

示例9: isAuthenticated

 /**
  * Try to authenticate using the username and password
  * Returns false on failure
  * @param string The username
  * @param string The password
  * @param Swift The instance of Swift this authenticator is used in
  * @return boolean
  */
 function isAuthenticated($user, $pass, &$swift)
 {
     //The authorization string uses ascii null as a separator (See RFC 2554)
     $credentials = base64_encode($user . chr(0) . $user . chr(0) . $pass);
     Swift_ClassLoader::load("Swift_Errors");
     Swift_Errors::expect($e, "Swift_ConnectionException");
     $swift->command("AUTH PLAIN " . $credentials, 235);
     if ($e) {
         $swift->reset();
         return false;
     }
     Swift_Errors::clear("Swift_ConnectionException");
     return true;
 }
開發者ID:jeffthestampede,項目名稱:excelsior,代碼行數:22,代碼來源:PLAIN.php

示例10: isAuthenticated

 /**
  * Try to authenticate using the username and password
  * Returns false on failure
  * @param string The username
  * @param string The password
  * @param Swift The instance of Swift this authenticator is used in
  * @return boolean
  */
 function isAuthenticated($user, $pass, &$swift)
 {
     Swift_ClassLoader::load("Swift_Errors");
     Swift_Errors::expect($e, "Swift_ConnectionException");
     $res =& $swift->command("AUTH CRAM-MD5", 334);
     if (!$e && instance_of($res, 'Swift_Events_ResponseEvent')) {
         $encoded_challenge = substr($res->getString(), 4);
         $challenge = base64_decode($encoded_challenge);
         $response = base64_encode($user . " " . $this->generateCRAMMD5Hash($pass, $challenge));
         $swift->command($response, 235);
     }
     if ($e !== null) {
         $swift->reset();
         return false;
     }
     Swift_Errors::clear("Swift_ConnectionException");
     return true;
 }
開發者ID:NaszvadiG,項目名稱:activecollab_loc,代碼行數:26,代碼來源:CRAMMD5.php

示例11: __construct

 /**
  * Constructor
  * @param mixed The data to use in the body
  * @param string Mime type
  * @param string The encoding format used
  * @param string The charset used
  */
 public function __construct($data = null, $type = "text/plain", $encoding = null, $charset = null)
 {
     parent::__construct();
     $this->setContentType($type);
     $this->setEncoding($encoding);
     $this->setCharset($charset);
     $this->setFlowed(false);
     if ($data !== null) {
         $this->setData($data);
         if ($charset === null) {
             Swift_ClassLoader::load("Swift_Message_Encoder");
             if (is_string($data) && Swift_Message_Encoder::instance()->isUTF8($data)) {
                 $this->setCharset("utf-8");
             } else {
                 $this->setCharset("iso-8859-1");
             }
             //The likely encoding
         }
     }
 }
開發者ID:enormego,項目名稱:EightPHP,代碼行數:27,代碼來源:Part.php

示例12: sentMail

 protected function sentMail($mailSubject, $mailBody)
 {
     if ($this->mailSwitch == true && !empty($this->mailAddress)) {
         $mailto = $this->mailAddress;
         apf_require_file("Swift.php");
         Swift_ClassLoader::load("Swift_Connection_SMTP");
         $smtpuser = APF::get_instance()->get_config("SmtpUser");
         $smtpemailto = $mailto;
         $message = new Swift_Message($mailSubject);
         $message->setFrom("安居客<" . $smtpuser . ">");
         $message->setTo($smtpemailto);
         $message->attach(new Swift_Message_Part(strip_tags($mailBody), "text/plain", "base64", "utf-8"));
         $message->attach(new Swift_Message_Part($mailBody, "text/html", "base64", "utf-8"));
         foreach ($smtpemailto as $to) {
             if (!empty($to)) {
                 @Mail_Queue::put($smtpuser, $to, $mailSubject, $message, Const_Mail::TYPE_SWIFT, Const_Mail::TYPE_ID_COMMUNITY_SUBSCRIBE);
             }
         }
     }
 }
開發者ID:emilymwang8,項目名稱:ajk-broker,代碼行數:20,代碼來源:MonitorBase.php

示例13: isAuthenticated

 /**
  * Try to authenticate using the username and password
  * Returns false on failure
  * @param string The username
  * @param string The password
  * @param Swift The instance of Swift this authenticator is used in
  * @return boolean
  */
 function isAuthenticated($user, $pass, &$swift)
 {
     Swift_ClassLoader::load("Swift_Errors");
     Swift_Errors::expect($e, "Swift_ConnectionException");
     if (!$e) {
         $swift->command("AUTH LOGIN", 334);
     }
     if (!$e) {
         $swift->command(base64_encode($user), 334);
     }
     if (!$e) {
         $swift->command(base64_encode($pass), 235);
     }
     if ($e) {
         $swift->reset();
         return false;
     }
     Swift_Errors::clear("Swift_ConnectionException");
     return true;
 }
開發者ID:jeffthestampede,項目名稱:excelsior,代碼行數:28,代碼來源:LOGIN.php

示例14: sendMail

 /**
  * 發送郵件
  * @param $mailSubject 標題
  * @param $mailBody 內容
  * @param array $mailTo 接受人,數組
  * @return bool
  */
 public function sendMail($mailSubject, $mailBody, $mailTo = array())
 {
     if (empty($mailSubject) || empty($mailBody) || empty($mailTo)) {
         return false;
     }
     apf_require_file("Swift.php");
     Swift_ClassLoader::load("Swift_Connection_SMTP");
     $smtpuser = APF::get_instance()->get_config("SmtpUser");
     $smtpemailto = $mailTo;
     $message = new Swift_Message($mailSubject);
     $message->setFrom("安居客<" . $smtpuser . ">");
     $message->setTo($smtpemailto);
     $message->attach(new Swift_Message_Part(strip_tags($mailBody), "text/plain", "base64", "utf-8"));
     $message->attach(new Swift_Message_Part($mailBody, "text/html", "base64", "utf-8"));
     foreach ($smtpemailto as $to) {
         if (!empty($to)) {
             @Mail_Queue::put($smtpuser, $to, $mailSubject, $message, Const_Mail::TYPE_SWIFT, Const_Mail::TYPE_ID_COMMUNITY_SUBSCRIBE);
         }
     }
     return true;
 }
開發者ID:emilymwang8,項目名稱:ajk-broker,代碼行數:28,代碼來源:ShowcaseCommon.php

示例15: go

 public function go()
 {
     try {
         Swift_ClassLoader::load("Swift_Cache_Disk");
         Swift_Cache_Disk::setSavePath(TestConfiguration::WRITABLE_PATH);
         Swift_CacheFactory::setClassName("Swift_Cache_Disk");
         $swift = new Swift($this->getConnection(), null, Swift::ENABLE_LOGGING);
         $this->setSwiftInstance($swift);
         $message = new Swift_Message("Smoke Test 3 - Attachment");
         $message->attach(new Swift_Message_Part("This message contains an attachment"));
         $message->attach(new Swift_Message_Part("This message contains an <em>attachment</em>", "text/html"));
         $message->attach(new Swift_Message_Attachment(new Swift_File(dirname(__FILE__) . "/../files/cv.pdf"), "Authors_CV.pdf", "application/pdf"));
         $to = new Swift_Address(TestConfiguration::TO_ADDRESS, TestConfiguration::TO_NAME);
         $from = new Swift_Address(TestConfiguration::FROM_ADDRESS, TestConfiguration::FROM_NAME);
         $swift->send($message, $to, $from);
         $this->to = $to->build();
         $this->from = $from->build();
     } catch (Exception $e) {
         $this->failed = true;
         $this->setError($e->getMessage());
     }
     $this->render();
 }
開發者ID:Esleelkartea,項目名稱:legedia-ESLE,代碼行數:23,代碼來源:runTestOfAttachment.php


注:本文中的Swift_ClassLoader類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。