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(); }
<?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) {
public function getCache() { Swift_Cache_Disk::setSavePath(TestConfiguration::WRITABLE_PATH); $cache = new Swift_Cache_Disk(); return $cache; }
/** * Set the save path of the disk - this is a global setting and called statically! * @param string The path to a writable directory */ public static function setSavePath($path = "/tmp") { self::$save_path = realpath($path); }