Beispiel #1
0
 public function testSetFrom()
 {
     $this->assertEquals($this->message, $this->message->setFrom($this->email));
     $this->headers->set('From', $this->email);
     $this->assertEquals($this->email, $this->message->getFrom());
     $this->assertEquals($this->headers->toString(), $this->message->getHeaders());
 }
Beispiel #2
0
 /**
  * Send E-mail message
  *
  * @param \Sendmail\Message $message
  *
  * @return boolean
  */
 public function send(Message $message)
 {
     $dialogue = new Dialogue($this->server, $this->port, $this->timeout);
     // SMTP-session is established, can send requests
     // is ESMTP?
     if ($dialogue->call('EHLO ' . $_SERVER['HTTP_HOST'])) {
         // open the TLS connection if need
         if ($this->secure) {
             $dialogue->call('STARTTLS');
             // after starting TLS need to say again EHLO
             $dialogue->call('EHLO ' . $_SERVER['HTTP_HOST'], true);
         }
     } else {
         $dialogue->call('HELO ' . $_SERVER['HTTP_HOST'], true);
     }
     // authorizing
     if ($this->auth_username && $this->auth_password) {
         $dialogue->call('AUTH LOGIN');
         $dialogue->call(base64_encode($this->auth_username));
         $dialogue->call(base64_encode($this->auth_password), true);
     }
     $dialogue->call('MAIL FROM: ' . $message->getFrom(), true);
     $dialogue->call('RCPT TO: ' . $message->getTo(), true);
     $dialogue->call('DATA');
     // point at the end means the end of the message
     $dialogue->call($message->getHeaders() . "\r\n\r\n" . $message->getText() . "\r\n.", true);
     // completes data transmission and close SMTP connect
     $result = $dialogue->call('QUIT');
     $dialogue->end();
     return $result;
 }