Exemplo n.º 1
0
 /**
  * Checks the address can be used in SMTP envelopes (no name).
  */
 public function testAddressCanBeReturnedForSMTPEnvelope()
 {
     $address = new Swift_Address("*****@*****.**", "FooBar");
     $this->assertEqual("<*****@*****.**>", $address->build(true));
     $address->setAddress("*****@*****.**");
     $this->assertEqual("<*****@*****.**>", $address->build(true));
 }
<?php

require_once dirname(__FILE__) . '/../bootstrap/unit.php';
# load fixtures of this plugin
$propelData->loadData(sfConfig::get('sf_plugins_dir') . '/sfNewsletterPlugin/data/fixtures');
$limeTest = new lime_test(4, new lime_output_color());
$recipientList = NewsletterRecipientList::createInstanceActiveSubscribers();
$limeTest->isa_ok($recipientList, 'NewsletterRecipientList', 'NewsletterRecipientList is valid.');
$limeTest->is(count($recipientList), 1, 'Found only valid subscribers.');
$subscriber = new Swift_Address('*****@*****.**', 'fourth subscriber');
/* @var $eachRecipient Swift_Address */
foreach ($recipientList->getBcc() as $eachRecipient) {
    $limeTest->is($eachRecipient->getName(), $subscriber->getName(), 'Subscriber name ok.');
    $limeTest->is($eachRecipient->getAddress(), $subscriber->getAddress(), 'Subscriber email ok.');
}
Exemplo n.º 3
0
/**
 * Send error log to administrator
 *
 * @param array $errors
 * @return boolean
 */
function backup_module_log_error($errors, $send_email = false)
{
    $log_message = is_foreachable($errors) ? implode("\n", $errors) : $errors;
    if ($send_email) {
        $mailer =& ApplicationMailer::mailer();
        $recipient = new Swift_Address();
        $recipient->setAddress(ADMIN_EMAIL);
        $recipient->setName('activeCollab admin');
        $sender = new Swift_Address();
        $sender->setAddress(ConfigOptions::getValue('notifications_from_email'));
        $sender->setName(ConfigOptions::getValue('notifications_from_name'));
        $tmp_message = "Automatic backup of activeCollab on " . ROOT_URL . " failed.\n\r";
        $tmp_message .= "Backup returned these errors: \n\r\n\r";
        $tmp_message .= $log_message;
        $message = new Swift_Message();
        $message->setSubject('activeCollab automatic backup error log');
        $message->setData($tmp_message);
        $message->setContentType('text/plain');
        $mailer->send($message, $recipient, $sender);
    }
    // if
    log_message($log_message, LOG_LEVEL_ERROR, 'backup');
}
Exemplo n.º 4
0
 public function testAddressHeadersAreInjectedBeforeSending()
 {
     $conn = new FullMockConnection();
     $conn->setReturnValueAt(0, "read", "220 xxx ESMTP");
     $conn->setReturnValueAt(1, "read", "250-Hello xxx\r\n250 HELP");
     $conn->setReturnValueAt(2, "read", "250 Ok");
     $conn->setReturnValueAt(3, "read", "250 Ok");
     $conn->setReturnValueAt(4, "read", "250 Ok");
     $conn->setReturnValueAt(5, "read", "354 Go ahead");
     $conn->setReturnValueAt(6, "read", "250 Ok");
     $conn->expectMinimumCallCount("write", 6);
     $conn->expectAt(0, "write", array("EHLO abc", "*"));
     $conn->expectAt(1, "write", array("MAIL FROM: <*****@*****.**>", "*"));
     $conn->expectAt(2, "write", array("RCPT TO: <*****@*****.**>", "*"));
     $conn->expectAt(3, "write", array("RCPT TO: <*****@*****.**>", "*"));
     $conn->expectAt(4, "write", array("DATA", "*"));
     $conn->expectAt(5, "write", array("*", "*"));
     $swift = new Swift($conn, "abc");
     $recipients = new Swift_RecipientList();
     $recipients->addTo("*****@*****.**", "XXX YYY");
     $recipients->addCc("*****@*****.**");
     $from = new Swift_Address("*****@*****.**", "Foo Bar");
     $message = new Message_RecipientsMocked();
     $message->__construct();
     $message->setSubject("the subject");
     $message->setBody("the body");
     $message->expectAt(0, "setTo", array(array("XXX YYY <*****@*****.**>")));
     $message->expectAt(0, "setCc", array(array("*****@*****.**")));
     $message->expectAt(0, "setFrom", array($from->build()));
     $swift->send($message, $recipients, $from);
 }