Beispiel #1
0
 /**
  * Send a message.
  * @method send
  * @param  \vakata\mail\MailInterface $mail the message to be sent
  * @return array              array with two keys - 'good' and 'bad' - indicating successfull and failed addresses
  */
 public function send(MailInterface $mail)
 {
     $all = array_merge($mail->getTo(true), $mail->getCc(true), $mail->getBcc(true));
     list($headers, $message) = explode("\r\n\r\n", (string) $mail, 2);
     $headers = explode("\r\n", preg_replace("(\r\n\\s+)", " ", $headers));
     foreach ($headers as $k => $v) {
         if (strtolower(substr($v, 0, 8)) === 'subject:') {
             unset($headers[$k]);
         }
         if (strtolower(substr($v, 0, 3)) === 'to:') {
             unset($headers[$k]);
         }
     }
     return @mail(implode(', ', $mail->getTo(true)), '=?utf-8?B?' . base64_encode((string) $mail->getSubject()) . '?=', $message, str_replace(" boundary=", "\r\n\t", implode("\r\n", $headers))) ? ['good' => $all, 'fail' => []] : ['fail' => $all, 'good' => []];
 }
Beispiel #2
0
 /**
  * Send a message.
  * @method send
  * @param  \vakata\mail\MailInterface $mail the message to be sent
  * @return array              array with two keys - 'good' and 'bad' - indicating successfull and failed addresses
  */
 public function send(MailInterface $mail)
 {
     $this->comm('MAIL FROM:<' . $mail->getFrom(true) . '>', [250]);
     $recp = array_merge($mail->getTo(true), $mail->getCc(true), $mail->getBcc(true));
     $badr = [];
     $good = [];
     foreach ($recp as $v) {
         try {
             $this->comm('RCPT TO:<' . $v . '>', [250, 251]);
             $good[] = $v;
         } catch (MailException $e) {
             $badr[] = $v;
         }
     }
     if (count($good)) {
         $this->comm('DATA', [354]);
         $data = (string) $mail;
         $data = explode("\n", str_replace(array("\r\n", "\r"), "\n", $data));
         foreach ($data as $line) {
             if (isset($line[0]) && $line[0] === '.') {
                 $line = '.' . $line;
             }
             $this->data($line . "\r\n");
         }
     }
     $this->comm('.', [250]);
     $this->comm('RSET', [250]);
     return ['good' => $good, 'fail' => $badr];
 }
Beispiel #3
0
 /**
  * Send a message.
  * @method send
  * @param  \vakata\mail\MailInterface $mail the message to be sent
  * @return array              array with two keys - 'good' and 'bad' - indicating successfull and failed addresses
  */
 public function send(MailInterface $mail)
 {
     $data = (string) $mail;
     file_put_contents($this->dir . DIRECTORY_SEPARATOR . time() . '_' . md5($data) . '.txt', $data);
     return ['good' => array_merge($mail->getTo(true), $mail->getCc(true), $mail->getBcc(true)), 'fail' => []];
 }