public function send(Message $message) { if (!is_writable($this->filepath)) { throw new \Laasti\Mailer\Exceptions\FileServerException('The message destination directory is not writeable: ' . $this->filepath); } $in = $message->toString(); $file = addslashes($this->filepath . '/' . date('Y-m-d H-i-s') . '-' . md5($in) . '.txt'); if (!file_put_contents($file, $in)) { throw new \Laasti\Mailer\Exceptions\FileServerException('Could not write message file to disk: ' . $file); } $this->logger && $this->logger->addDebug('Mail saved: ' . $file); return true; }
/** * 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(); $in .= $this->CRLF . $this->CRLF . "." . $this->CRLF; $code = $this->pushStack($in); if ($code !== '250') { throw new CodeException('250', $code, array_pop($this->resultStack)); } return $this; }
public function send(Message $message) { $in = $message->toString(); $email = !is_null($message->getFakeFromEmail()) ? $message->getFakeFromEmail() : $message->getFromEmail(); // is popen() enabled? if (!function_exists('popen') || FALSE === ($fp = @popen($this->mailpath . ' -oi -f ' . $email . ' -t -r ' . $email, 'w'))) { // server probably has popen disabled, so nothing we can do to get a verbose error. throw new SendException('The message could not be delivered using sendmail. The function popen() is disabled.'); } fputs($fp, $message->headersToString()); fputs($fp, $in); $status = pclose($fp); if ($status !== 0) { throw new SendException('Cannot open a socket to Sendmail. Check settings. Status code: ' . $status . '.'); } $this->logger && $this->logger->addDebug('Sent: ' . $message->getHeader('To')); return true; }