Giter VIP home page Giter VIP logo

mailmagik's Introduction

Checkout our latest project

  • With DocPHT you can take notes and quickly document anything and without the use of any database.

Latest release GitHub license Maintenance Open Source Love Downloads

⭐ If you use it, you should star it on Github! It's the least you can do for all the work put into it!

πŸͺ„ Mailmagik for Kanboard

Have you ever found yourself struggling with the process of creating a task in Kanboard via email? Maybe someone recommended the Mailgun Plugin, but you ended up feeling frustrated and out of pocket when you discovered its cost. Or perhaps someone suggested using Zapier and API, but you were left scratching your head and wondering what on earth they were talking about.

Well, fear not! We have the solution for you. Our plugin is easy to install and allows you to connect to an IMAP server of your choice. With just a few clicks, you'll be creating tasks like a pro in no time.

Say goodbye to confusion and frustration, and say hello to Mailmagik! Join us today and let's make task creation a breeze.

This plugin allows you to connect Kanboard directly to an IMAP server. Once connected, you can:

  1. Send emails directly to a task
  2. Send emails to a project to automatically be converted into a task within the project
  3. Send emails to a task to automatically convert into a task comment
  4. Adds a Trigger Event that can be called using the Crontab

For #2 & #3

  • Using the Daily Background Job for Tasks: You will need to setup the automatic actions in the project config, and there MUST be at least 1 open task within the project
  • Using the Mailmagik mail fetching trigger: You will need to setup the automatic actions in the project config

For #2

  • The sender of the mail must be a member of the targeted project, with the permission to create new tasks.

For #4

  • Trigger using: ./cli mailmagik:fetchmail
  • Example of adding to crontab to run independently of Daily Background Job:
0 8 * * * cd /var/www/app && ./cli cronjob >/dev/null 2>&1
* * * * * cd /var/www/app && ./cli mailmagik:fetchmail

Since release 1.4.0, mail fetching can also be triggered by a webcron system. Simply invoke the URL

https://<your_server>/?controller=FetchmailController&plugin=Mailmagik&action=run&token=<your_token>

You'll get

mailmagik:fetchmail executed

as a response.

Once installed, setup in Settings > Email settings:
image

The Parse Option allows you to choose how to parse the actions, using the TO: field or the SUBJECT: field

When using the TO: option, see examples below:

When using the SUBJECT: option, see examples below:

  • to send an email directly to a task: [Task#1] should appear at the start of the Subject
  • to send an email to a project for task conversion: [Project#1] should appear at the start of the Subject
  • to send an email to a task for comment conversion: [CommentOnTask#1] should appear at the start of the Subject
  • note: the action must be in brackets

Emails sent to a task can be found in the Task uner the "Task Email" icon on the sidebar:
image

In order to setup automatic conversions of email, you will need to add the Actions to the project.

When sending emails for automatic Task Conversion, MailMagik can parse the subject line to add attributes to the Task:

in Subject Effect
d:YYYY-MM-DD Set due date
s:YYYY-MM-DD Set start date
p:n Set priority n
c:name Set category 'name'
t:name Add tag 'name', may be repeated. Non-existing tags will be created, beware of typos.
col:name Set column 'name' to bypass default column

A subject line containing

Test c:SQL p:3 d:2023-02-28 s:2023-02-20

will create a priority 3 task named "Test", category "SQL", start on Feb 20 and due on Feb 28.

Attribute values for category, column and tags must be quoted, in case they consist of multiple words. Quoting chars can be any of "", '', β€˜β€™, β€œβ€, «» and β€žβ€œ. Example: col:"Work in progress".

image

The plugin can also parse the email body for task attributes. Use the following syntax: Enclose the assignment with

  • &@ @& for standard task attributes
  • $@ @$ for metamagik fields

Examples:

&@category_id=foo bar@&
&@column_id=Done@&
&@priority=3@&

$@Custom_field="Lorem ipsum"@$

Optionally, this assignments can be removed from email body after processing.

When parsing dates from email body, a textual representation can be user instead of a date. This works for both, standard- and custom date fields. Example:

&@date_due=next Friday@&

These texts must be in English language and cannot be translated.

Plugin Authors:

Collaborators and Contributors:

Requirements

https://github.com/barbushin/php-imap#requirements

If you are using the docker containter of Kanboard, simply remote into it and:

apk update
apk add php-imap
apk add php81-fileinfo

PHP 7.4 Check:

php -m | grep -i imap
$ sudo apt-get install php-imap
$ sudo apt-get install php7.4-imap
$ sudo apt-get install -y php-fileinfo

Run both commands

Install

Automatically

  1. If your Kanboard installation is configured to install from the app, simply find it in the plugins directory and choose install.
  2. Restart your server

Manually

  1. Download the latest versions supplied zip file, it should be named Mailmagik-x.xx.x.zip
  • I advise not to install from source or master
  1. Unzip to the plugins folder.
  • your folder structure should look like the following:
plugins
└── Mailmagik            <= Plugin name
    β”œβ”€β”€ Action  
    β”œβ”€β”€ Assets  
    β”œβ”€β”€ Controller  
    β”œβ”€β”€ Template
    β”œβ”€β”€ vendor
    β”œβ”€β”€ LICENSE
    β”œβ”€β”€ CHANGELOG.MD
    β”œβ”€β”€ Makefile
    β”œβ”€β”€ Plugin.php   
    β”œβ”€β”€ README.md
    β”œβ”€β”€ composer.json
    └── composer.lock

3.) Restart your server

Troubleshooting

  1. If you are getting OP_READONLY complaints about an undefined variable, then you are missing the php-imap requirement, install req, enable and restart server.

mailmagik's People

Contributors

alfredbuehler avatar aljawaid avatar creecros avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mailmagik's Issues

PHP 8.1 deprecated notices.

PHP message: PHP Deprecated: date_create(): Passing null to parameter #1 ($datetime) of type string is deprecated in /var/www/app/plugins/Mailmagik/Action/ConvertEmailToTask.php on line 279"

Seperate from general cronjob

          @creecros  I recommend not to put the email polling through the general cron job instead to define a seperate cron job. 

Let me explain a problem I encounterd .

The general cron job also used to sent out reminders for tasks that are due , so we could set only daily schdule for it.

But for taks generation through email , should be somthing to be executed at least hourly.

So putting both jobs in same cron will flood up the email inbox if you have enabled the email notifications.

Originally posted by @isvfgs in #16 (comment)

Task attributes are not removed from task email subject

If email notification is enabled, the task-creation confirmation contains the full subject, including all attribute definitions.

New Task t:foo t:bar t:"foo bar" c:Test (#79)

This additional content is considered as unwanted.

Emails with no subject

Null subject is an issue, causing a break and fail in the mark as read email, causing an infinite loop of task creation.

Fatal error: Uncaught TypeError: Kanboard\Plugin\Mailmagik\Action\ConvertEmailToTask::scanSubject(): Argument #1 ($subject) must be of type string, null given, called in /var/www/app/plugins/Mailmagik/Action/ConvertEmailToTask.php on line 155 and defined in /var/www/app/plugins/Mailmagik/Action/ConvertEmailToTask.php:189

Inline images are not rendered

If an email contains an inline image it shows like this in kb:

![PastedGraphic-1.png](data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAACRgAAAGECAYAAABX6d7xAAAKsmlDQ1BJQ0MgUHJvZmlsZQAASImVlwdUU+kSgP9700MChIRQpITepAsEkBJCC6....

Any ideas, how to have the image rendered?

[xx-xxx-xxxxx xx:xx:xx Europe/Berlin] [critical] Mailmagik: ["Can not authenticate to IMAP server: [AUTHENTICATIONFAILED] Authentication failed."]

From #25 by @JustFxDev

0.) Fatal Error
An incorrect imap e-mal password or something like that disables the plug in. It disappears from the list of installed plugins. This leads to this situation: I cannot correct the password in the application setting / e-mal setup. The fields are no longer there.

Even a new installation does not change this, because the wrong information is still in the database.

I fixed that by changing it directly in the database.

That occurred also as the server had certification problems (this was the reason why I found that initial out)

Error-log:
[xx-xxx-xxxxx xx:xx:xx Europe/Berlin] [critical] Mailmagik: ["Can not authenticate to IMAP server: [AUTHENTICATIONFAILED] Authentication failed."]

Rendering issue

Added settings to mailmagik (v1.2.3) configuration, hit save and lost layout and save button preventing any further edits.
Verified in Safari & Chrome. Using Docker based Kanboard

Application version: v1.2.34
PHP version: 8.3.0
PHP SAPI: fpm-fcgi
HTTP Client: cURL
OS version: Linux 6.5.9-arch2-1
Database driver: postgres
Database version: 13.10 (Debian 13.10-1.pgdg110+1)
Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15

kanboardrenderissue

Error With No Values

This error is after installing (folder starts with capital K), and when accessing Task Email sidebar menu inside a task. no mailbox details have been entered in settings yet.

[php7:error] [pid 1183151] [client 86.000.166.135:59386] PHP Fatal error:  Uncaught Error: Undefined constant 'OP_READONLY' in /var/www/my.domain/public_html/plugins/Kbphpimap/Controller/EmailViewController.php:180

Converting task email to task

when converting a task email to a task:

2023/02/23 13:49:08 [error] 15#15: *1 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught PicoDb\SQLException: SQL Error[HY000]: SQLSTATE[HY000]: General error: 5 database is locked in /var/www/app/libs/picodb/lib/PicoDb/StatementHandler.php:353,
  thrown in /var/www/app/libs/picodb/lib/PicoDb/StatementHandler.php on line 353" while reading upstream, client: 172.17.0.1, server: localhost, request: "GET /?controller=FileViewerController&action=thumbnail&file_id=4&task_id=6 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm.sock:", host: "192.168.1.2:41111"

i think its happening too fast....will need to look into

Allow the use of IMAP-subfolders

If you have the option to sort out Kanboard mails into subfolders on the server, e.g. by ManageSieve or similar, you can specify that folder instead of INBOX. This might be helpful, if you use the mailbox for other things than Kanboard mailings.

  • Mailmagik searches for available folders and let you select one.
  • Mailmagik will scan the designated folder instead of the INBOX.
  • The default is still INBOX.

image

Feature request: E-Mail Adresse

Hi Creecros,

sorry, it's my again.

I would like to suggest to transfer the adressing to a Task, Comment or Project from the E-Mail adress to the subject of an E-Mail. Reason:

If i send an e-mail to Task #20 i use

Task#20 <[email protected]>

Works fine. Perfect.

If i send then an e-mail to Task#21 <[email protected]> my E-Mail Client (Thunderbird and i think Outlook & Co. will do this as well) gives my

Task#20 <[email protected]>

as the target adress. This is not a simple Text. It is an e-mail field which can not simply be changed. I have then to use the local menu and choose edit E-Mail (field)
grafik

and have to change this. Each time i use an other task nr. This is because the client maintains a history of used e-mail adresses.

Furthermore it seams that Task is case sensitiv on the PlugIn side. I would suggest to have this not to be case sensitive CommentOnTask and Project as well..

This PlugIn is a real time saver for working with Kanboard. Great work! Thanks!

Cheers, Fx

Subject parsing: Multi word attribute values not possible

The current implementation isn't capable of extracting multi-word attribute values. E.g., it's not possible to create a new task directly in a column like β€œWork in progress”.

This issue relates to categories, columns, and tags.

Emails not fetching

Hello, I'm using a brand new install o Kanboard 1.2.30, on Debian 12 running Apache, PostgreSQL and PHP 7.4

Kanboard its the only thing running on this server, and its installed at /var/www/html/kanboard

All modules appear to be installed correctly, as shown by php -m

[PHP Modules]
calendar Core ctype curl date dom exif FFI fileinfo filter ftp gd gettext hash iconv imap json ldap libxml mbstring openssl pcntl pcre PDO pdo_pgsql pgsql Phar posix readline Reflection session shmop SimpleXML sockets sodium SPL standard sysvmsg sysvsem sysvshm tokenizer xml xmlreader xmlwriter xsl Zend OPcache zip zlib

[Zend Modules]
Zend OPcache

Mailmagik plugin v1.2.2 installed without issues and is configured, the automatic actions are configured as well

When I run /var/www/html/./cli mailmagik:fetchmail it appears to run correctly and finishes without error, apache2 don't show any error

Yet, nothing happens, the emails are not marked as read or deleted depending on config, no tasks are created on the board

I tried with a Microsoft account and a brand new Gmail account with imap activated, and app password set, neither the standard account password or the app password worked

I suspect something happens when Mailmagik tries fetching the emails and fails, but I don't know where are the log files for that operation, where I can find the logs?

Thank you.

Cronjob Link just for Mailmagik

Discussed in #39

Originally posted by chocwithstarfish January 4, 2024
Hello, I'm currently using the predefined URL for the Kanboard cron job (https://domain.tld/?controller=CronjobController&action=run&token==WEBHOOK_TOKEN_HERE) which executes all scheduled tasks, including email notifications. I am interested in whether there is a way to specifically target the Mailmagik email fetch function with a cron job link, so I can run it every 10 minutes independently of the full cron job, which I prefer running once daily. Any guidance on setting up a more frequent, specific cron job for Mailmagik would be greatly appreciated.

Mailmagik broken due to Symfony updates

I don't know the exact version, but since Kanboard version > 1.2.28 the plugin Mailmagik doesn't work anymore.
Edit: The problem came up between 1.2.30 and 1.2.31.

Installed in Kanboard 1.2.27, no parsing options

I just installed Kanboard 1.2.27 using Docker which looks to be functioning fine.
Tried to install Mailmagik 1.2.1. When configuring Kanboard crashes immediately complaining about Undefined constant 'OP_READONLY', even though I followed the instructions to install php-imap and php81-fileinfo in the container. After removing the plugin folder I was able to get back in Kanboard.
Then installed Mailmagik 1.2.0. I can configure it without a problem. Only thing that I see is that there is no pane to select the parsing options, neither with 1.2.0 nor 1.2.1...

Kanboard does not seem to fetch the emails I sent to a specifically created gmail address (which uses 2FA, and I did get an app password for Mailmagik).

How can I debug?

Error When Installing

I got this when installing... site is down unless I delete the plugin

[php7:error] [pid 1182489] [client 86.189.166.135:58946] PHP Fatal error:  Uncaught Error: Class 'Kanboard\\Plugin\\Kbphpimap\\Action\\ConvertEmailToTask' not found in /var/www/my.domain/public_html/plugins/kbphpimap/Plugin.php:27\nStack trace:\n#0 /var/www/my.domain/public_html/app/Core/Plugin/Loader.php(127): Kanboard\\Plugin\\Kbphpimap\\Plugin->initialize()\n#1 /var/www/my.domain/public_html/app/Core/Plugin/Loader.php(67): Kanboard\\Core\\Plugin\\Loader->initializePlugin()\n#2 /var/www/my.domain/public_html/app/ServiceProvider/PluginProvider.php(27): Kanboard\\Core\\Plugin\\Loader->scan()\n#3 /var/www/my.domain/public_html/vendor/pimple/pimple/src/Pimple/Container.php(290): Kanboard\\ServiceProvider\\PluginProvider->register()\n#4 /var/www/my.domain/public_html/app/common.php(58): Pimple\\Container->register()\n#5 /var/www/my.domain/public_html/index.php(6): require('/var/www/my.domain')\n#6 {main}\n  thrown in /var/www/my.domain/public_html/plugins/kbphpimap/Plugin.php on line 27

Task not getting created Unless at least one task is there in the project

First of all good work. This plugin indeed a good required addition to the kanboard.
I would like to inform an issue noticed

When I send email to create the task, it is not getting created t unless there is at least one task already created mannually through the interface.

Steps to create.

  1. Create a new project
  2. Setup all the necessary auto actions.
  3. Note down the project id and send mail to create the task

->Problem : Task is not created. ( mail is not getting the read status )

  1. Create a task in that project through the interface
  2. The task send through mail get created after the first task

Feature request: add E-Mail attachment to Task

Hi there!

Another great plugin! I would like to suggest a feature request:

If the incoming e-mail has one or more attachments (real attachments, not in the mail embeddied stuff), add that attachemt to the documents of the task. Regardless if the mail goes to a task or a to comment. If comment is the target, than the documents of the task for that comment should be the target to attach to.

This would be great to integrate mail closer to Kanboard. One can send and store important e-mails (attached to the mail which goes to Kanboard Task / Comment) for the whole team in Kanboard. At the moment i put such mails to the desktop and upload them manually to a task as an attachment.

Thanks for that plugin!

Cheers, Fx

Extracting task attributes from the subject

I'm working on a nice feature for the ConvertEmailToTask action. The subject is scanned for some task attributes. It found they are extracted/removed from the subject and applied to the newly created task. I saw a similar concept on my Toodledo account, found it very helpful when creating tasks by e-mail.

I'm still on testing, but the following attributes are already implemented:

in Subject Effect
d:YYYY-MM-DD Set due date
s:YYYY-MM-DD Set start date
p:n Set priority n
c:name Set category 'name'
t:name Add tag 'name', may be repeated. Non-existing tags will be created, beware of typos.

A subject line containing

Test c:SQL p:3 d:2023-02-28 s:2023-02-20

will create a priority 3 task named "Test", category "SQL", start on Feb 20 and due on Feb 28.

image

The pending work is, implementing the tags attribute, which is a bit more complicated, as there is more than one possible.

Any feedback is appreciated.

EDIT: Amended tagging

Sent E-Mails are not being fetched and converted

Unfortunately after setting this up in my installation on a Shared hoster E-Mails didn't make it into the Project.

What I tried so far (w/o success):
β€’ Port set to 143
β€’ Port set to empty
β€’ Advanced settings set to /readonly
β€’ Advanced settings set to empty (will be replaced by /imap/ssl after "Save")
β€’ Username set to E-Mail address as well as serverinternal Username
β€’ Selected "Parse from the "SUBJECT" field" and send emails with appropriate Prefix
β€’ Selected "Parse from the "TO" field" and send emails with appropriate Prefix
β€’ used the CLI on the server to "php cli mailmagik:fetchmail"

Automatic action is set to:
β€’ Automatically Convert Emails to Tasks
Event name = Trigger Mailmagik mail fetching
Column = To be done (An existing column)
Color = Red

QUESTION:

  1. Is there a way I can debug w/o having access to server logs
  2. What else can be changed to narrow down the issue?
  3. How else can I test if Mailmagik can "see" the content in an IMAP folder?

I'm looking for ages for such a feature! Thank you for providing it at all.

P.S. It's the latest Kanboard and all Plugins are up-to-date.

Error/Exception when fetching mails from Exchange server

When trying to deploy this plugin we ran into Internal Error: Could not search mailbox!

After some jiggery-pokery we arrived at the relevant info, dumping the exception. This gave us

           [message:protected] => IMAP method imap_search() failed with error: [BADCHARSET (US-ASCII)] The specified charset is not supported.

which led us to the following part of php-imap

    /**
     * This function uses imap_search() to perform a search on the mailbox currently opened in the given IMAP stream.
     * For example, to match all unanswered mails sent by Mom, you'd use: "UNANSWERED FROM mom".
     *
     * @param string $criteria              See http://php.net/imap_search for a complete list of available criteria
     * @param bool   $disableServerEncoding Disables server encoding while searching for mails (can be useful on Exchange servers)
     *
     * @return int[] mailsIds (or empty array)
     *
     * @psalm-return list<int>
     */
    public function searchMailbox(string $criteria = 'ALL', bool $disableServerEncoding = false): array
    {

the relevant part being Disables server encoding while searching for mails (can be useful on Exchange servers). We applied this to

$mails_ids = $mailbox->searchMailbox($filter);
by adding a ,true after $filter and this fixed the issue.

I don't know if there's a way to auto detect it or whether to disable it by default or make it configurable, but here it is.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.