Added transport class for MailOutput.

This commit is contained in:
2016-08-04 15:52:59 +02:00
parent f237e37a28
commit 1af2c621f4
4 changed files with 45 additions and 3 deletions

View File

@@ -98,7 +98,10 @@ class MailOutput extends GenericOutput
$this->setHeadersFromString($headers);
$recipients = implode(', ', $this->recipients);
// TODO: Check if any recipients in the first place
$mail_sent = mail($recipients, $this->subject, $mailbody, $this->getHeaders());
return $mail_sent;
$this->transport->setRecipients($recipients);
$this->transport->setSubject($this->subject);
$this->transport->setHeaders($this->getHeaders());
$this->transport->setContent($mailbody);
return $this->transport->send();
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace Frs\Output\Transport;
class MailTransport implements TransportInterface
{
private $recipients;
private $subject;
private $headers;
private $content;
public function setContent($content)
{
$this->content = $content;
}
public function setRecipients($recipients)
{
$this->recipients = $recipients;
}
public function setSubject($subject)
{
$this->subject = $subject;
}
public function setHeaders($headers)
{
$this->headers = $headers;
}
public function transmit()
{
return mail($this->recipients, $this->subject, $this->content, $this->headers);
}
}

View File

@@ -14,5 +14,6 @@ class StdoutTransport implements TransportInterface
public function transmit()
{
echo $this->content;
return true;
}
}