Esempio n. 1
0
 /**
  * @dataProvider serverProvider
  */
 public function testSendMultipleToCcBcc($server, $port, $secure, $username, $password)
 {
     $token = $this->generateSubjectToken();
     $smtp = new fSMTP($server, $port, $secure, 10);
     if ($username) {
         $smtp->authenticate($username, $password);
     }
     $email = new fEmail();
     $email->setFromEmail($username ? $username : '******');
     $email->addRecipient(EMAIL_ADDRESS, 'Test User');
     $email->addRecipient(str_replace('@', '_2@', EMAIL_ADDRESS), 'Test User 2');
     $email->addCCRecipient(str_replace('@', '_3@', EMAIL_ADDRESS), 'Test User 3');
     $email->addBCCRecipient(str_replace('@', '_4@', EMAIL_ADDRESS), 'Test User 4');
     $email->setSubject($token . ': Testing Multiple Recipients');
     $email->setBody('This is a test of sending multiple recipients');
     $message_id = $email->send($smtp);
     $message = $this->findMessage($token, EMAIL_USER);
     $this->assertEquals($message_id, $message['headers']['message-id']);
     $this->assertEquals($username ? $username : '******', $message['headers']['from']['mailbox'] . '@' . $message['headers']['from']['host']);
     $this->assertEquals($token . ': Testing Multiple Recipients', $message['headers']['subject']);
     $this->assertEquals('This is a test of sending multiple recipients', trim($message['text']));
     $message = $this->findMessage($token, str_replace('tests', 'tests_2', EMAIL_USER));
     $this->assertEquals(array('personal' => 'Test User', 'mailbox' => 'tests', 'host' => 'flourishlib.com'), $message['headers']['to'][0]);
     $message = $this->findMessage($token, str_replace('tests', 'tests_3', EMAIL_USER));
     $this->assertEquals(array('personal' => 'Test User 3', 'mailbox' => 'tests_3', 'host' => 'flourishlib.com'), $message['headers']['cc'][0]);
     $message = $this->findMessage($token, str_replace('tests', 'tests_4', EMAIL_USER));
     $this->assertEquals(FALSE, isset($message['headers']['bcc']));
     $smtp->close();
 }
Esempio n. 2
0
 /**
  * @dataProvider serverProvider
  */
 public function testSendMultipleToCcBcc($server, $port, $secure, $username, $password)
 {
     $token = $this->generateSubjectToken();
     $smtp = new fSMTP($server, $port, $secure, 5);
     if ($username) {
         $smtp->authenticate($username, $password);
     }
     $email = new fEmail();
     $email->setFromEmail($username ? $username : '******');
     $email->addRecipient(EMAIL_ADDRESS, 'Test User');
     $email->addRecipient(str_replace('@', '_2@', EMAIL_ADDRESS), 'Test User 2');
     $email->addCCRecipient(str_replace('@', '_3@', EMAIL_ADDRESS), 'Test User 3');
     $email->addBCCRecipient(str_replace('@', '_4@', EMAIL_ADDRESS), 'Test User 4');
     $email->setSubject($token . ': Testing Multiple Recipients');
     $email->setBody('This is a test of sending multiple recipients');
     $message_id = $email->send($smtp);
     $message = $this->findMessage($token, EMAIL_USER);
     $this->assertEquals($message_id, $message['headers']['Message-ID']);
     $this->assertEquals($username ? $username : '******', $message['headers']['From']);
     $this->assertEquals($token . ': Testing Multiple Recipients', $message['headers']['Subject']);
     $this->assertEquals('This is a test of sending multiple recipients', trim($message['plain']));
     $message = $this->findMessage($token, str_replace('tests', 'tests_2', EMAIL_USER));
     // It seems the windows imap extension doesn't support the personal part of an email address
     $is_windows = stripos(php_uname('a'), 'windows') !== FALSE;
     $this->assertEquals($is_windows ? '*****@*****.**' : '"Test User" <*****@*****.**>', $message['headers']['To']);
     $message = $this->findMessage($token, str_replace('tests', 'tests_3', EMAIL_USER));
     $this->assertEquals($is_windows ? '*****@*****.**' : '"Test User 3" <*****@*****.**>', $message['headers']['Cc']);
     $message = $this->findMessage($token, str_replace('tests', 'tests_4', EMAIL_USER));
     $this->assertEquals(FALSE, isset($message['headers']['Bcc']));
     $smtp->close();
 }