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(); }
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(); }
/** * 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"); }
<?php /** * Benchmarking tests for Swift Mailer * @author Chris Corbyn <*****@*****.**> */ set_time_limit(500); error_reporting(E_ALL); ini_set("display_errors", "On"); require_once "../TestConfiguration.php"; //Number of emails to send $n = isset($_GET["n"]) ? $_GET["n"] : 1; require_once TestConfiguration::SWIFT_LIBRARY_PATH . "/Swift.php"; Swift_CacheFactory::setClassName("Swift_Cache_Disk"); Swift_Cache_Disk::setSavePath(TestConfiguration::WRITABLE_PATH); $conn = null; switch (TestConfiguration::CONNECTION_TYPE) { case "smtp": require_once TestConfiguration::SWIFT_LIBRARY_PATH . "/Swift/Connection/SMTP.php"; $enc = null; $test_enc = TestConfiguration::SMTP_ENCRYPTION; if ($test_enc == "ssl") { $enc = Swift_Connection_SMTP::ENC_SSL; } elseif ($test_enc == "tls") { $enc = Swift_Connection_SMTP::ENC_TLS; } $conn = new Swift_Connection_SMTP(TestConfiguration::SMTP_HOST, TestConfiguration::SMTP_PORT, $enc); if ($user = TestConfiguration::SMTP_USER) { $conn->setUsername($user); } if ($pass = TestConfiguration::SMTP_PASS) {
/** * Set the name of the class which is supposed to be used * This also includes the file * @param string The class name */ public static function setClassName($name) { Swift_ClassLoader::load($name); self::$className = $name; }
/** * Constructor */ public function __construct() { Swift_ClassLoader::load("Swift_Message_Headers"); $this->setHeaders(new Swift_Message_Headers()); Swift_ClassLoader::load("Swift_CacheFactory"); $this->cache = Swift_CacheFactory::getCache(); }
/** * 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 string * @throws Swift_FileException If the file cannot be read */ function &encode8BitFile($file, $chunk = 76, $le = "\r\n") { Swift_ClassLoader::load("Swift_CacheFactory"); if (!is_a($file, "Swift_File")) { trigger_error("The file passed MUST be an instance of Swift_File."); return; } $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)); $os =& $cache->getOutputStream("8b"); return $os; }
/** * Constructor */ function Swift_Message_Mime() { Swift_ClassLoader::load("Swift_Message_Encoder"); $this->_encoder =& Swift_Message_Encoder::instance(); Swift_ClassLoader::load("Swift_Message_Headers"); $headers =& new Swift_Message_Headers(); $this->setHeaders($headers); Swift_ClassLoader::load("Swift_CacheFactory"); $this->cache =& Swift_CacheFactory::getCache(); }