本文整理汇总了PHP中Swift_ClassLoader::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Swift_ClassLoader::load方法的具体用法?PHP Swift_ClassLoader::load怎么用?PHP Swift_ClassLoader::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Swift_ClassLoader
的用法示例。
在下文中一共展示了Swift_ClassLoader::load方法的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();
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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
}
}
}
示例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);
}
}
}
}
示例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;
}
示例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;
}
示例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();
}