/** * @expectedException Laasti\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); }
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; }
public function send(Message $message) { // most documentation of sendmail using the "-f" flag lacks a space after it, however // we've encountered servers that seem to require it to be in place. $sent = mail($message->getHeader('To'), $message->getSubject(), $message->getEncodedBody(true), $message->headersToString(), '-f ' . $message->getHeader('Return-Path')); if ($sent) { $this->logger && $this->logger->addDebug('Sent: ' . $message->getHeader('To')); } else { throw new SendException('The message could not be delivered using mail().'); } return $sent; }
/** * 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; }
public function send(Message $message) { $this->logger && $this->logger->addDebug('Should have sent: ' . $message->getHeader('To')); return true; }
/** * set mail charset * @param string $charset * @return $this */ public function setCharset($charset) { $this->message->setCharset($charset); return $this; }