diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-10-16 20:50:12 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-10-16 20:50:12 -0400 |
commit | f99a3c501fd6ed7b4914b8d6e855489c2ce5b219 (patch) | |
tree | 976276d6acfff78923e4549b0ef9ea94c5e2cb0d /app/Integration/Mailgun.php | |
parent | 9c9ed02cd7ebc5dbbc99bcaed6f80988ce8a9677 (diff) |
Make mail transports pluggable and move integrations to plugins
- Postmark: https://github.com/kanboard/plugin-postmark
- Mailgun: https://github.com/kanboard/plugin-mailgun
- Sendgrid: https://github.com/kanboard/plugin-sendgrid
Diffstat (limited to 'app/Integration/Mailgun.php')
-rw-r--r-- | app/Integration/Mailgun.php | 95 |
1 files changed, 0 insertions, 95 deletions
diff --git a/app/Integration/Mailgun.php b/app/Integration/Mailgun.php deleted file mode 100644 index 045284d2..00000000 --- a/app/Integration/Mailgun.php +++ /dev/null @@ -1,95 +0,0 @@ -<?php - -namespace Kanboard\Integration; - -use Kanboard\Core\Tool; - -/** - * Mailgun Integration - * - * @package integration - * @author Frederic Guillot - */ -class Mailgun extends \Kanboard\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) - { - $headers = array( - 'Authorization: Basic '.base64_encode('api:'.MAILGUN_API_TOKEN) - ); - - $payload = array( - 'from' => sprintf('%s <%s>', $author, MAIL_FROM), - 'to' => sprintf('%s <%s>', $name, $email), - 'subject' => $subject, - 'html' => $html, - ); - - $this->httpClient->postForm('https://api.mailgun.net/v3/'.MAILGUN_DOMAIN.'/messages', $payload, $headers); - } - - /** - * Parse incoming email - * - * @access public - * @param array $payload Incoming email - * @return boolean - */ - public function receiveEmail(array $payload) - { - if (empty($payload['sender']) || empty($payload['subject']) || empty($payload['recipient'])) { - return false; - } - - // The user must exists in Kanboard - $user = $this->user->getByEmail($payload['sender']); - - if (empty($user)) { - $this->container['logger']->debug('Mailgun: ignored => user not found'); - return false; - } - - // The project must have a short name - $project = $this->project->getByIdentifier(Tool::getMailboxHash($payload['recipient'])); - - if (empty($project)) { - $this->container['logger']->debug('Mailgun: ignored => project not found'); - return false; - } - - // The user must be member of the project - if (! $this->projectPermission->isMember($project['id'], $user['id'])) { - $this->container['logger']->debug('Mailgun: ignored => user is not member of the project'); - return false; - } - - // Get the Markdown contents - if (! empty($payload['stripped-html'])) { - $description = $this->htmlConverter->convert($payload['stripped-html']); - } - else if (! empty($payload['stripped-text'])) { - $description = $payload['stripped-text']; - } - else { - $description = ''; - } - - // Finally, we create the task - return (bool) $this->taskCreation->create(array( - 'project_id' => $project['id'], - 'title' => $payload['subject'], - 'description' => $description, - 'creator_id' => $user['id'], - )); - } -} |