summaryrefslogtreecommitdiff
path: root/app/Integration
diff options
context:
space:
mode:
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;