[New Plugin] Configure and use fetchmail from the WebApp



  • No problem, happens to the best of us ;-)



  • now indeed it comes up fine. Thanks a lot!



  • Question @Kopano

    Do you think it would be worth having a common area, sourcecode, packages or whatever where plugins like this are available for all users?

    I.e. a central repository where people can go in and search which plugins are available in addition to the official Kopano ones?


  • Kopano

    @mcostan yes, we have that already on our agenda. As a matter of fact I just added some more links and made it public. You can find it at https://stash.z-hub.io/projects/COM/repos/projects-and-resources/browse

    @olia would you be so kind to run through the explained workflow in https://stash.z-hub.io/projects/COM/repos/projects-and-resources/browse/CONTRIBUTING.md and add your project? I am interested if the instructions are clear enough or need to be clarified/simplified. Thanks!



  • @fbartels
    I’ve read the document, and followed it (waiting to hear back for write access to the repo).
    Also the instructions are clear enough.


  • Kopano

    @olia thanks, I just replied to your request.



  • Hi,
    I am not a very skilled Linux user, but i come as far as getting the Fetchmail plugin show up as a plugin. But as soon as i go to the Options in Kopano, i get a Http 500 internal server error as long as the plugin is enabled. So i must be doing something wrong. I’ll try to describe what i have done:

    I use a Univention debian distro in a virtual machine. I installed Kopano-core & Kopano-webapp & got that working, including sending mail via a smart relay host.

    Installed Requierements ( i think)

    • fetchmail: dpkg -l | grep fetchmail shows it as installed
    • libproc-daemon-perl: installed via apt-get
    • MTA on the host machine (postfix): is working, i can send mail
    • Database to store account informations (At the moment only ‘mysql’ is supported): i did not take specific action on this, i presume Kopano-core install took care of this?

    I was able to download, install & activate the plugin; it shows up in the options in kopano-webapp.

    I copied the example.config.php in the <kopano-webapp>/plugins/fetchmail folder to config.php ** in the same folder ** and customized the ‘changethis!’ part in define(‘PLUGIN_FETCHMAIL_PASSWORDS_AES_KEY’, “changethis!”)

    i did not create a user to run the fetchmail daemon (i found the (default: fetchmail/nogroup) )
    i did not Manual: Set the rights for the home directory to 600.
    i did not Edit the <kopano-webapp>/plugins/fetchmail/php/daemon/kopano_fetchmail.pl if you used non-standard options.

    i Started the daemon with perl kopano_fetchmail.pl --start and no errors where shown.

    I still have to create a startup script. (see kopano_fetchmail.service.example for a systemd config).

    I did not make any symlinks as previously posted?

    Thanks in advance



  • @pwhooftman said in [New Plugin] Configure and use fetchmail from the WebApp:

    Hi,
    I am not a very skilled Linux user, but i come as far as getting the Fetchmail plugin show up as a plugin. But as soon as i go to the Options in Kopano, i get a Http 500 internal server error as long as the plugin is enabled. So i must be doing something wrong. I’ll try to describe what i have done:

    mmm, it seems i have to do something in the database department after all:
    [Mon May 07 11:17:14.629544 2018] [:error] [pid 2652] [client 10.0.0.225:3311] PHP Fatal error: Uncaught Error: Class ’

    mysqli’ not found in /usr/share/kopano-webapp/plugins/fetchmail/php/drivers/class.MysqlDatabaseDriver.php:39\nStack trac

    e:\n#0 /usr/share/kopano-webapp/plugins/fetchmail/php/class.pluginfetchmailmodule.php(167): MysqlDatabaseDriver->__const

    ruct(‘localhost’, ‘3306’, ‘kopano’, ‘kopano_fetchmai…’, ‘kopano_fetchmai…’, ‘password’, ‘********’)\n#1 /usr/shar

    e/kopano-webapp/plugins/fetchmail/php/class.pluginfetchmailmodule.php(180): PluginFetchmailModule->getDatabaseConnection

    ()\n#2 /usr/share/kopano-webapp/plugins/fetchmail/php/class.pluginfetchmailmodule.php(86): PluginFetchmailModule->getLis

    tOfFetchmailAccounts()\n#3 /usr/share/kopano-webapp/server/includes/core/class.jsonrequest.php(57): PluginFetchmailModul

    e->execute()\n#4 /usr/share/kopano-webapp/kopano.php(137): JSONRequest->execute(’{“zarafa”:{"plu…’)\n#5 {main}\n thro

    wn in /usr/share/kopano-webapp/plugins/fetchmail/php/drivers/class.MysqlDatabaseDriver.php on line 39, referer: http://1

    0.0.0.168/webapp/



  • @pwhooftman
    Update: i reinstalled phpmyadmin, and now the error states: Cannot connect to database. So, progress :-)

    But if i look in phpmyadmin no fetchmail user or table(s) for the plugin are present. Do i have to set up the mysql for the plugin myself (user, tables, etc) , or is that something the daemon should take care of?



  • Update: got it working

    1. Fetchmail was not installed yet :-|
    2. set mysql root users password
    3. changed mysql user & password to root in config.php


  • Do you think it would be possible to have a plugin for the the other direction so that it’s possible to set for each User Account several smtp Server in the same way as you made it possible for the fetchmail function.

    Best Carmen



  • I have install the Plugin.
    In the Webapp is all running fine.
    But the kopano_fetchmail.pl make Errors

    Odd number of elements in hash assignment at kopano_fetchmail.pl line 142, <$fetchmail_api> line 1.
    Use of uninitialized value $account{“entryid”} in concatenation (.) or string at kopano_fetchmail.pl line 161, <$fetchmail_api> line 1.
    Use of uninitialized value $account{“entryid”} in concatenation (.) or string at kopano_fetchmail.pl line 168, <$fetchmail_api> line 1.
    Use of uninitialized value $account{“src_server”} in concatenation (.) or string at kopano_fetchmail.pl line 170, <$fetchmail_api> line 1.
    Use of uninitialized value in concatenation (.) or string at kopano_fetchmail.pl line 170, <$fetchmail_api> line 1.
    Use of uninitialized value in concatenation (.) or string at kopano_fetchmail.pl line 170, <$fetchmail_api> line 1.

    Can Anyone help me???



  • its older but here is my how to for Ubuntu 18.04

    Install the Requirements.

    apt install fetchmail libproc-daemon-perl
    

    by installing fetchmail you see the following strings like this:
    Adding system user fetchmail' (UID 119) ... Adding new userfetchmail’ (UID 119) with group nogroup' ... Creating home directory/var/lib/fetchmail’ …

    Download and unzip the fetchmail-1.0.zip to the ‘plugins’ folder in your kopano-webapp installation (default:
    /usr/share/kopano-webapp/plugins/

    cd /tmp
    wget https://github.com/olia-dev/kopano-webapp-fetchmail/archive/master.zip
    unzip master.zip -d /tmp/fetchmail
    cd /tmp/fetchmail/kopano-webapp-fetchmail-master/builds
    unzip fetchmail-1.0.2.zip -d /usr/share/kopano-webapp/plugins/
    cd /usr/share/kopano-webapp/plugins/fetchmail
    mv example.config.php /etc/kopano/webapp/config-fetchmail.php
    ln -s /etc/kopano/webapp/config-fetchmail.php config.php
    

    Create Fetchmail User & Database in MYSQL

    sudo mysql -u root -p 
    
    CREATE DATABASE kopano_fetchmail DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
    CREATE USER 'kopano_fetchmail'@'localhost' IDENTIFIED BY 'SeCrEtPasSwOrD';
    GRANT ALL PRIVILEGES ON kopano_fetchmail.* TO 'kopano_fetchmail'@'localhost';
    FLUSH PRIVILEGES;
    
    quit
    

    Edit your settings:

    nano /etc/kopano/webapp/config-fetchmail.php
    

    Edit if you used non-standard options (none in my case)

    nano /php/daemon/kopano_fetchmail.pl
    

    Start the daemon with

    perl /usr/share/kopano-webapp/plugins/fetchmail/php/daemon/kopano_fetchmail.pl --start
    

    Create System startup script. (see kopano_fetchmail.service.example for a systemd config).
    use this example to /etc/systemd/system/

    mv /usr/share/kopano-webapp/plugins/fetchmail/kopano_fetchmail.service.example /usr/share/kopano-webapp/plugins/fetchmail/kopano_fetchmail.service
    
    ln -s /usr/share/kopano-webapp/plugins/fetchmail/kopano_fetchmail.service /etc/systemd/system/kopano_fetchmail.service
    

    The system service script shows at following

    nano /etc/systemd/system/kopano_fetchmail.service``` 
    
    [Unit]
    Description=Fetchmail daemon for kopano-webapp plugin 'fetchmail'
    After=mysql.service kopano-server.service
    
    [Service]
    Type=forking
    Environment=LC_ALL=C LANG=C
    PIDFile=/var/lib/fetchmail/kopano_fetchmail_daemon.pid
    ExecStart=/usr/bin/perl /usr/share/kopano-webapp/plugins/fetchmail/php/daemon/kopano_fetchmail.pl --start
    ExecStop=/usr/bin/perl /usr/share/kopano-webapp/plugins/fetchmail/php/daemon/kopano_fetchmail.pl --stop
    TimeoutStopSec=60
    
    [Install]
    WantedBy=multi-user.target
    

    Stop the daemon

    perl /usr/share/kopano-webapp/plugins/fetchmail/php/daemon/kopano_fetchmail.pl --stop
    

    Enable fail2rest service to run at startup

    systemctl enable kopano_fetchmail.service
    

    Run the following systemd command to start the fail2rest service

    systemctl start kopano_fetchmail.service
    

    Verify that the fail2rest service it is active and running

    systemctl status kopano_fetchmail.service
    

Log in to reply