summaryrefslogtreecommitdiff
path: root/app/Integration
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-06-13 13:17:16 -0400
committerFrederic Guillot <fred@kanboard.net>2015-06-13 13:17:16 -0400
commitf2abf339120751f11f729606b46927332f886a1d (patch)
tree46976ea48e812b18903b2bde2d84ab113bc0708f /app/Integration
parent7ba9b2d9b9b8426aacabcb7e3e4a0c08d2be5444 (diff)
Add Sendgrid as mail transport
Diffstat (limited to 'app/Integration')
-rw-r--r--app/Integration/Sendgrid.php (renamed from app/Integration/SendgridWebhook.php)32
1 files changed, 29 insertions, 3 deletions
diff --git a/app/Integration/SendgridWebhook.php b/app/Integration/Sendgrid.php
index 9125f00b..902749f6 100644
--- a/app/Integration/SendgridWebhook.php
+++ b/app/Integration/Sendgrid.php
@@ -6,21 +6,47 @@ use HTML_To_Markdown;
use Core\Tool;
/**
- * Sendgrid Webhook
+ * Sendgrid Integration
*
* @package integration
* @author Frederic Guillot
*/
-class SendgridWebhook extends \Core\Base
+class Sendgrid extends \Core\Base
{
/**
+ * Send a HTML email
+ *
+ * @access public
+ * @param string $email
+ * @param string $name
+ * @param string $subject
+ * @param string $html
+ * @param string $author
+ */
+ public function sendEmail($email, $name, $subject, $html, $author)
+ {
+ $payload = array(
+ 'api_user' => SENDGRID_API_USER,
+ 'api_key' => SENDGRID_API_KEY,
+ 'to' => $email,
+ 'toname' => $name,
+ 'from' => MAIL_FROM,
+ 'fromname' => $author,
+ 'html' => $html,
+ 'subject' => $subject,
+ );
+
+ $this->httpClient->postForm('https://api.sendgrid.com/api/mail.send.json', $payload);
+ }
+
+ /**
* Parse incoming email
*
* @access public
* @param array $payload Incoming email
* @return boolean
*/
- public function parsePayload(array $payload)
+ public function receiveEmail(array $payload)
{
if (empty($payload['envelope']) || empty($payload['subject'])) {
return false;