Added transport class for MailOutput.
This commit is contained in:
parent
f237e37a28
commit
1af2c621f4
@ -7,6 +7,7 @@ use \Frs\SessionManager;
|
|||||||
use \Frs\Output\HtmlOutput;
|
use \Frs\Output\HtmlOutput;
|
||||||
use \Frs\Output\MailOutput;
|
use \Frs\Output\MailOutput;
|
||||||
use \Frs\Output\Transport\StdoutTransport;
|
use \Frs\Output\Transport\StdoutTransport;
|
||||||
|
use \Frs\Output\Transport\MailTransport;
|
||||||
|
|
||||||
$stdout = new StdoutTransport();
|
$stdout = new StdoutTransport();
|
||||||
$ho = new HtmlOutput($stdout, dirname(__FILE__) . '/templates');
|
$ho = new HtmlOutput($stdout, dirname(__FILE__) . '/templates');
|
||||||
@ -70,7 +71,8 @@ if (!$tpl_done && $sm->hasSessionToken()) {
|
|||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'send':
|
case 'send':
|
||||||
echo 'This would send the mail...';
|
echo 'This would send the mail...';
|
||||||
$mo = new MailOutput(dirname(__FILE__) . '/templates');
|
$mt = new MailTransport();
|
||||||
|
$mo = new MailOutput($mt, dirname(__FILE__) . '/templates');
|
||||||
$form_type = $_REQUEST['form_type'];
|
$form_type = $_REQUEST['form_type'];
|
||||||
$mo->setTemplate('mail_' . $form_type);
|
$mo->setTemplate('mail_' . $form_type);
|
||||||
$skey = 'form_' . $form_type;
|
$skey = 'form_' . $form_type;
|
||||||
|
@ -98,7 +98,10 @@ class MailOutput extends GenericOutput
|
|||||||
$this->setHeadersFromString($headers);
|
$this->setHeadersFromString($headers);
|
||||||
$recipients = implode(', ', $this->recipients);
|
$recipients = implode(', ', $this->recipients);
|
||||||
// TODO: Check if any recipients in the first place
|
// TODO: Check if any recipients in the first place
|
||||||
$mail_sent = mail($recipients, $this->subject, $mailbody, $this->getHeaders());
|
$this->transport->setRecipients($recipients);
|
||||||
return $mail_sent;
|
$this->transport->setSubject($this->subject);
|
||||||
|
$this->transport->setHeaders($this->getHeaders());
|
||||||
|
$this->transport->setContent($mailbody);
|
||||||
|
return $this->transport->send();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
36
lib/Frs/Output/Transport/MailTransport.php
Normal file
36
lib/Frs/Output/Transport/MailTransport.php
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
@ -14,5 +14,6 @@ class StdoutTransport implements TransportInterface
|
|||||||
public function transmit()
|
public function transmit()
|
||||||
{
|
{
|
||||||
echo $this->content;
|
echo $this->content;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user