Test with Google Script to send mail. This works and seems to be the
only way without going through registration process with Google.
This commit is contained in:
parent
a756549343
commit
ba7520caad
@ -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);
|
||||
|
47
lib/Frs/Output/Transport/GScriptTransport.php
Normal file
47
lib/Frs/Output/Transport/GScriptTransport.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Frs\Output\Transport;
|
||||
|
||||
class GScriptTransport implements TransportInterface
|
||||
{
|
||||
private $content;
|
||||
private $subject;
|
||||
private $headers = array();
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->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 '<html><body><form method="post" action="' . $this->post_url . '">';
|
||||
echo '<input type="text" name="subject" value="' . $this->subject . '"/>';
|
||||
echo '<textarea name="body">' . $this->content . '</textarea>';
|
||||
echo '<input type="submit" value="Send"/>';
|
||||
echo '</form></body></html>';
|
||||
return true;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user