本文整理汇总了PHP中Swift_ClassLoader类的典型用法代码示例。如果您正苦于以下问题:PHP Swift_ClassLoader类的具体用法?PHP Swift_ClassLoader怎么用?PHP Swift_ClassLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Swift_ClassLoader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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("安居客<[email protected]>");
$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('[email protected]', $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
示例16: 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 5 - Embedded Image");
$part = new Swift_Message_Part("\n Here is an embedded image: <br />\n <img src=\"" . $message->attach(new Swift_Message_Image(new Swift_File(dirname(__FILE__) . "/../files/manchester.jpeg"))) . "\" alt=\"image\" /><br />And here is the rest of the message.", "text/html");
$message->attach($part);
$message->attach(new Swift_Message_Part("You are viewing this message in plain text. Switch to HTML mode to see the image.", "text/plain"));
$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,代码来源:runTestOfEmbeddedImage.php
示例17: dirname
<?php
/**
* Swift Mailer SMTP Connection component.
* Please read the LICENSE file
* @author Chris Corbyn <[email protected]>
* @package Swift_Connection
* @license GNU Lesser General Public License
*/
require_once dirname(__FILE__) . "/../ClassLoader.php";
Swift_ClassLoader::load("Swift_ConnectionBase");
Swift_ClassLoader::load("Swift_Authenticator");
/**
* Swift SMTP Connection
* @package Swift_Connection
* @author Chris Corbyn <[email protected]>
*/
class Swift_Connection_SMTP extends Swift_ConnectionBase
{
/**
* Constant for TLS connections
*/
const ENC_TLS = 2;
/**
* Constant for SSL connections
*/
const ENC_SSL = 4;
/**
* Constant for unencrypted connections
*/
const ENC_OFF = 8;
开发者ID:sho5kubota,项目名称:guidingyou2,代码行数:31,代码来源:SMTP.php
示例18: encode8BitFile
/**
* Return a 8bit string from a file
* @param Swift_File The file stream to read from
* @param int Max line length (including CRLF)
* @param string The line ending
* @return Swift_Cache_OutputStream
* @throws Swift_FileException If the file cannot be read
*/
public function encode8BitFile(Swift_File $file, $chunk = 76, $le = "\r\n")
{
Swift_ClassLoader::load("Swift_CacheFactory");
$cache = Swift_CacheFactory::getCache();
$ret = "";
while (false !== ($bytes = $file->read(8192))) {
$ret .= $bytes;
}
$cache->write("8b", $this->fixLE(wordwrap($ret, $chunk - 2, $le, 1), $le));
return $cache->getOutputStream("8b");
}
开发者ID:IngenioContenidoDigital,项目名称:americana,代码行数:19,代码来源:Encoder.php
示例19: dirname
<?php
/**
* Swift Mailer Message Decorating Plugin.
* Please read the LICENSE file
* @author Chris Corbyn <[email protected]>
* @package Swift_Plugin
* @subpackage Decorator
* @license GNU Lesser General Public License
*/
require_once dirname(__FILE__) . "/../ClassLoader.php";
Swift_ClassLoader::load("Swift_Events_BeforeSendListener");
Swift_ClassLoader::load("Swift_Events_SendListener");
Swift_ClassLoader::load("Swift_Plugin_Decorator_Replacements");
/**
* Swift Decorator Plugin.
* Allows messages to be slightly different for each recipient.
* @package Swift_Plugin
* @subpackage Decorator
* @author Chris Corbyn <[email protected]>
*/
class Swift_Plugin_Decorator implements Swift_Events_BeforeSendListener, Swift_Events_SendListener
{
/**
* The replacements object.
* @var Swift_Plugin_Decorator_Replacements
*/
protected $replacements;
/**
* Temporary storage so we can restore changes we make.
* @var array
开发者ID:enormego,项目名称:EightPHP,代码行数:31,代码来源:Decorator.php
示例20: dirname
<?php
/**
* EasySwift Response Tracker
* Please read the LICENSE file
* @copyright Chris Corbyn <[email protected]>
* @author Chris Corbyn <[email protected]>
* @package EasySwift
* @license GNU Lesser General Public License
*/
require_once dirname(__FILE__) . "/../ClassLoader.php";
Swift_ClassLoader::load("Swift_Events_ResponseListener");
/**
* EasySwift, Swift Response Tracker.
* Updates properties in EasySwift when a response is received by Swift.
* @package EasySwift
* @author Chris Corbyn <[email protected]>
*/
class Swift_Plugin_EasySwiftResponseTracker implements Swift_Events_ResponseListener
{
/**
* The target object to update
* @var EasySwift
*/
protected $target = null;
/**
* Constructor
* @param EasySwift The instance of EasySwift to run against
*/
public function __construct($obj)
{
开发者ID:darkcolonist,项目名称:kohana234-doctrine115,代码行数:31,代码来源:EasySwiftResponseTracker.php
注:本文中的Swift_ClassLoader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论