From ba7520caad3e94e602fd11ade79395adda688a0b Mon Sep 17 00:00:00 2001 From: Markus Birth Date: Sat, 4 Feb 2017 01:26:18 +0100 Subject: [PATCH] Test with Google Script to send mail. This works and seems to be the only way without going through registration process with Google. --- index.php | 5 +- lib/Frs/Output/Transport/GScriptTransport.php | 47 +++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 lib/Frs/Output/Transport/GScriptTransport.php diff --git a/index.php b/index.php index 496884a..545f59e 100644 --- a/index.php +++ b/index.php @@ -7,7 +7,7 @@ use \Frs\SessionManager; use \Frs\Output\HtmlOutput; use \Frs\Output\MailOutput; use \Frs\Output\Transport\StdoutTransport; -use \Frs\Output\Transport\GmailTransport; +use \Frs\Output\Transport\GScriptTransport; $stdout = new StdoutTransport(); $ho = new HtmlOutput($stdout, dirname(__FILE__) . '/templates'); @@ -71,7 +71,8 @@ if (!$tpl_done && $sm->hasSessionToken()) { switch ($action) { case 'send': echo 'This would send the mail...'; - $mt = new GmailTransport($sm); + //$mt = new MailTransport($sm); + $mt = new GScriptTransport(); $mo = new MailOutput($mt, dirname(__FILE__) . '/templates'); $form_type = $_REQUEST['form_type']; $mo->setTemplate('mail_' . $form_type); diff --git a/lib/Frs/Output/Transport/GScriptTransport.php b/lib/Frs/Output/Transport/GScriptTransport.php new file mode 100644 index 0000000..7c46932 --- /dev/null +++ b/lib/Frs/Output/Transport/GScriptTransport.php @@ -0,0 +1,47 @@ +post_url = 'https://script.google.com/macros/s/AKfycbxVcugiTBTvWx8DK_HhuQh_vXdteir6GTXE_Anir3rfovatjQM/exec'; + } + + public function setParam($key, $value) + { + switch ($key) { + case 'to': + // ignored + break; + + case 'subject': + $this->subject = $value; + break; + + case 'headers': + $this->headers = $value; + break; + } + } + + public function setContent($content) + { + $this->content = $content; + } + + public function transmit() + { + echo '
'; + echo ''; + echo ''; + echo ''; + echo '
'; + return true; + } +}