Beispiel #1
0
 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');
 }
Beispiel #2
0
 /**
  * @param Mail $mail Mail.
  *
  * @return $this
  */
 public function sendMail(Mail $mail)
 {
     $this->getCurl()->setOption(CURLOPT_MAIL_FROM, $mail->getFrom());
     $this->getCurl()->setOption(CURLOPT_MAIL_RCPT, [$mail->getTo()]);
     $this->getCurl()->setMethod('PUT');
     $this->getCurl()->setPutString($mail);
     $this->getCurl()->execute();
     return $this;
 }