Example #1
0
 /**
  * Send the given Message.
  *
  * Recipient/sender data will be retrieved from the Message API.
  * The return value is the number of recipients who were accepted for delivery.
  *
  * @param MessageInterface $message
  *
  * @return int
  */
 public function send(MessageInterface $message)
 {
     $smtp_conn = fsockopen($this->host, $this->port, $errno, $errstr, 10);
     $log = $this->get_data($smtp_conn);
     fputs($smtp_conn, "EHLO " . $this->username . "\r\n");
     $log = $this->get_data($smtp_conn);
     fputs($smtp_conn, "AUTH LOGIN\r\n");
     $log = $this->get_data($smtp_conn);
     fputs($smtp_conn, base64_encode($this->username) . "\r\n");
     $log = $this->get_data($smtp_conn);
     fputs($smtp_conn, base64_encode($this->password) . "\r\n");
     $log = $this->get_data($smtp_conn);
     $size_msg = strlen($message->toString());
     fputs($smtp_conn, "MAIL FROM:<" . $this->username . "> SIZE=" . $size_msg . "\r\n");
     $log = $this->get_data($smtp_conn);
     foreach ($message->getTo() as $userMail => $userName) {
         fputs($smtp_conn, "RCPT TO: <" . $userMail . ">" . "\r\n");
         $log = $this->get_data($smtp_conn);
     }
     fputs($smtp_conn, "DATA" . "\r\n");
     $log = $this->get_data($smtp_conn);
     fputs($smtp_conn, $message->toString() . "\r\n.\r\n");
     $log = $this->get_data($smtp_conn);
     fputs($smtp_conn, "QUIT\r\n");
     $log = $this->get_data($smtp_conn);
     return count($message->getTo());
 }
Example #2
0
 /**
  * Send the given Message.
  *
  * Recipient/sender data will be retrieved from the Message API.
  * The return value is the number of recipients who were accepted for delivery.
  *
  * @param MessageInterface $message
  * @return int
  */
 public function send(MessageInterface $message)
 {
     $messageStr = $message->toString();
     $toArr = $this->getTo($messageStr);
     $to = implode(', ', array_keys($toArr));
     $subject = $message->getSubject();
     $endHeaders = strpos($messageStr, MessageInterface::LINE_SEPARATOR . MessageInterface::LINE_SEPARATOR);
     $headers = substr($messageStr, 0, $endHeaders);
     $body = substr($messageStr, $endHeaders + 4);
     if (!mail($to, $subject, $body, $headers)) {
         return 0;
     } else {
         return count($message->getTo());
     }
 }
Example #3
0
 /**
  * Send the given Message.
  *
  * Recipient/sender data will be retrieved from the Message API.
  * The return value is the number of recipients who were accepted for delivery.
  *
  * @param MessageInterface $message
  *
  * @return int
  */
 public function send(MessageInterface $message)
 {
     $eol = Message::LINE_SEPARATOR;
     $messageString = $message->toString();
     $startBoundary = strpos($messageString, 'boundary');
     $endBoundary = strpos($messageString, $eol . $eol, $startBoundary);
     $startContent = $endBoundary;
     $content = substr($messageString, $startContent + strlen($eol . $eol));
     $messageString = substr_replace($messageString, '', $startContent) . $eol . $eol;
     $messageString = str_replace($eol . 'boundary', $eol . ' ' . 'boundary', $messageString);
     $content = str_replace($eol . 'boundary', $eol . ' ' . 'boundary', $content);
     if (mail(null, null, $content, $messageString)) {
         return count($message->getTo());
     } else {
         return '0';
     }
 }