/**
  * @expectedException \Tx\Mailer\Exceptions\SMTPException
  */
 public function testConnectSMTPException()
 {
     $this->smtp->setServer("localhost", "99999", null)->setAuth('none', 'none');
     $message = new Message();
     $message->setFrom('You', '*****@*****.**')->setTo('Them', '*****@*****.**')->setSubject('This is a test')->setBody('This is a test part two');
     $this->smtp->send($message);
 }
Example #2
0
 public function testSMTP()
 {
     $this->smtp->setServer(self::SERVER, self::PORT)->setAuth(self::USER, self::PASS);
     // email, password
     $this->message->setFrom('Tom', '*****@*****.**')->setFakeFrom('heelo', '*****@*****.**')->addTo('Cloud', '*****@*****.**')->setSubject('Test SMTP ' . time())->setBody('<h1>for test</h1>')->addAttachment('host', __FILE__);
     $status = $this->smtp->send($this->message);
     $this->assertTrue($status);
     usleep(self::DELAY);
 }
 public function testSendEmailBySmtp()
 {
     $this->client->shouldReceive('send')->with(m::on(function ($value) {
         $message = new Message();
         $message->setFrom("*****@*****.**", "*****@*****.**");
         $message->setTo("*****@*****.**", "*****@*****.**");
         $message->setSubject("Foo");
         $message->setBody("Bar");
         return $message == $value;
     }));
     $this->module->sendEmailBySmtp("*****@*****.**", "*****@*****.**", "Foo", "Bar");
 }
 /**
  * SMTP DATA
  * SUCCESS 354
  * SUCCESS 250
  * @return $this
  * @throws CodeException
  * @throws SMTPException
  */
 protected function data()
 {
     $in = "DATA" . $this->CRLF;
     $code = $this->pushStack($in);
     if ($code !== '354') {
         throw new CodeException('354', $code, array_pop($this->resultStack));
     }
     $in = $this->message->toString();
     $code = $this->pushStack($in);
     if ($code !== '250') {
         throw new CodeException('250', $code, array_pop($this->resultStack));
     }
     return $this;
 }
Example #5
0
 public function sendEmailBySmtp($from, $to, $subject, $body)
 {
     $this->_createSmtpClient();
     $message = new Message();
     $message->setFrom($from, $from);
     $message->setTo($to, $to);
     $message->setSubject($subject);
     $message->setBody($body);
     $this->client->send($message);
 }
Example #6
0
 /**
  * add mail attachment
  * @param $name
  * @param $path
  * @return $this
  */
 public function addAttachment($name, $path)
 {
     $this->message->addAttachment($name, $path);
     return $this;
 }