コード例 #1
0
ファイル: MailTest.php プロジェクト: blar/mail
 public function testCurlTransport()
 {
     $mail = new Mail();
     $mail->setTo('*****@*****.**');
     $headers = $mail->getHeaders();
     $headers->set('To', '*****@*****.**');
     $headers->set('X-Foo', 23);
     $headers->set('X-Bar', 42);
     $headers->set('X-Foo-Bar', 1337);
     if (getEnv('TRAVIS')) {
         $from = new MailAddress();
         $from->setMailbox(getEnv('USER'));
         $from->setHostName(getHostName());
         $headers->set('From', $from);
         $headers->set('Subject', sprintf('%s #%s (%s)', getEnv('TRAVIS_REPO_SLUG'), getEnv('TRAVIS_JOB_NUMBER'), __METHOD__));
         $headers->set('Content-Type', 'text/plain');
         $mail->push(sprintf("Repository: %s\nJob: %s\nCommit: %s\nCommit-Range: %s\nPHP-Version: %s\n", getEnv('TRAVIS_REPO_SLUG'), getEnv('TRAVIS_JOB_NUMBER'), getEnv('TRAVIS_COMMIT'), getEnv('TRAVIS_COMMIT_RANGE'), getEnv('TRAVIS_PHP_VERSION')));
     } else {
         $headers->set('From', '*****@*****.**');
         $mail->push("Hello World");
     }
     $credentials = getEnv('MAILTRAP_SMTP_CREDENTIALS');
     if (!$credentials) {
         $this->markTestSkipped('Credentials for Mailtrap not found!');
     }
     $credentials = explode(':', $credentials, 2);
     $transport = new CurlTransport('mailtrap.io', 2525);
     $transport->setCredentials($credentials[0], $credentials[1]);
     $transport->sendMail($mail);
     # $this->markTestIncomplete('Check sent mail via Mailtrap is not implemented');
 }
コード例 #2
0
ファイル: AddressCollection.php プロジェクト: blar/mail
 /**
  * @return AddressCollection
  */
 public static function parse($addressCollection)
 {
     $result = imap_rfc822_parse_adrlist($addressCollection, getHostname());
     $addressCollection = new static($result);
     return $addressCollection->map(function ($user) {
         if (!$user->host) {
             throw new Exception('Missing or invalid host name');
         }
         if ($user->host == '.SYNTAX-ERROR.') {
             throw new Exception('Missing or invalid host name');
         }
         $mailAddress = new MailAddress();
         if (property_exists($user, 'personal')) {
             $mailAddress->setUserName($user->personal);
         }
         $mailAddress->setMailbox($user->mailbox);
         $mailAddress->setHostname($user->host);
         return $mailAddress;
     });
 }
コード例 #3
0
ファイル: MailAddressTest.php プロジェクト: blar/mail
 public function testAddressWithFluidInterface()
 {
     $mailAddress = new MailAddress();
     $mailAddress->setUserName('foo bar')->setMailbox('foobar')->setHostName('example.com');
     $this->assertEquals('foo bar', $mailAddress->getUserName());
     $this->assertEquals('foobar', $mailAddress->getMailbox());
     $this->assertEquals('example.com', $mailAddress->getHostName());
     $this->assertEquals('*****@*****.**', $mailAddress->getEmail());
     $this->assertEquals('foo bar <*****@*****.**>', (string) $mailAddress);
 }