From 52d3ceb66eb38e834b998b7e236d062b119ab385 Mon Sep 17 00:00:00 2001 From: Ben P Date: Thu, 30 Dec 2021 17:29:25 -0700 Subject: [PATCH] Allow flags for connecting to IMAP server to be specified in config.php and update README to show how to use a non-self-hosted IMAP server. --- README.md | 12 ++++++++---- config.php | 3 ++- index.php | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1f874f2..24ca248 100644 --- a/README.md +++ b/README.md @@ -25,22 +25,26 @@ The email address is composed like: ## B. For NextCloud admins to setup ### Requirements -This app requires php-curl, php-imap and Postfix. +This app requires php-curl, php-imap and some sort of imap server (e.g. Postfix with Courier). ### NC new user Create a new user from User Management on your NC server, which will have to function as a bot. We chose to call him *deckbot*, but you can call it however you want.
__Note__: that you have to assign *deckbot* on each board you want to add new cards from email. -### Set up Postfix for incoming email +### Configure Email +#### Option 1 - Set up Postfix for incoming email You can setup Posfix mail server folowing the instructions on [Posfix setup](https://docs.gitlab.com/ee/administration/reply_by_email_postfix_setup.html), and after that add "+" delimiter (which separe the user from the board in the email address) using the command:
``` sudo postconf -e "recipient_delimiter = +" ``` +#### Option 2 - Use an existing email server. +This could be any hosted email service. The only requirement is that you can connect to it via the IMAP protocol. +*Please note this option may not be as flexible as a selfhosted server. For example your email service may not support the "+"delimeter for directing messages to a specific board* ### Download and install -Clone this repository into *incoming* user.
+If using a self-hosted Postfix server, clone this repository into *incoming* user. If not you may need to create a new user on your system and adjust the commands in future steps to match that username.
``` cd /home/incoming/ git clone https://github.com/putt1ck/mail2deck.git mail2deck ``` -Edit as you need the config file: +Edit the config file as you need: ``` sudo nano /home/incoming/mail2deck/config.php ``` diff --git a/config.php b/config.php index caef093..8481193 100644 --- a/config.php +++ b/config.php @@ -3,6 +3,7 @@ define("NC_SERVER", ""); // server.domain define("NC_USER", "deckbot"); define("NC_PASSWORD", ""); define("MAIL_SERVER", ""); // server.domain +define("MAIL_SERVER_FLAGS", "/no-validate-cert" // flags needed to connect to server. Refer to https://www.php.net/manual/en/function.imap-open.php for a list of valid flags. define("MAIL_USER", "incoming"); define("MAIL_PASSWORD", ""); -?> \ No newline at end of file +?> diff --git a/index.php b/index.php index bcb688f..238e825 100644 --- a/index.php +++ b/index.php @@ -3,7 +3,7 @@ error_reporting(E_ERROR | E_PARSE); require_once("config.php"); require_once('lib/DeckClass.php'); -$inbox = imap_open("{" . MAIL_SERVER . "/imap/novalidate-cert}INBOX", MAIL_USER, MAIL_PASSWORD) +$inbox = imap_open("{" . MAIL_SERVER . "/imap" . MAIL_SERVER_FLAGS . "}INBOX", MAIL_USER, MAIL_PASSWORD) or die("can't connect:" . imap_last_error()); $emails = imap_search($inbox, 'UNSEEN'); @@ -97,4 +97,4 @@ if ($emails) } imap_close($inbox); -?> \ No newline at end of file +?>