Skip to content
Recover your email attachments from your cloud
PHP Makefile
Branch: master
Clone or download
Latest commit 1dd4f83 Jul 4, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
appinfo 0.3.0 Jul 4, 2019
lib 0.3.0 Jul 4, 2019
screenshots first commit Oct 29, 2017
.gitignore Added Netbeans project files Jun 25, 2019 first commit Oct 29, 2017
LICENSE first commit Oct 29, 2017
Makefile 0.3.0 Jul 4, 2019 add test Jul 4, 2019
composer.json 0.3.0 Jul 4, 2019
composer.lock 0.3.0 Jul 4, 2019


Scrutinizer Code Quality

Files From Mail allow an admin to link a drop-mailbox to Nextcloud.
This way, you can set a mail address ( in our example) and every mails+attachments send to this mail address will be automatically be saved on the cloud.


This app will need Mailparse
If not already installed on your server:

$ sudo pecl install mailparse

If the installation failed with a message about mbstring not installed (but mbstring is already installed) you will need to install the Mailparse extension manually:

$ pecl download mailparse
$ tar -zxvf mailparse-3.0.2.tgz
$ cd mailparse-3.0.2/
$ phpize
$ vi mailparse.c

remove lines 34-37:

#if !HAVE_MBSTRING                                                                                                                                                                    
#error The mailparse extension requires the mbstring extension!                                                                                                                       
$ ./configure --with-php-config=/usr/bin/php-config
$ make
$ sudo make install
$ sudo echo "" > /etc/php/7.0/mods-available/mailparse.ini
$ sudo ln -s /etc/php/7.0/mods-available/mailparse.ini /etc/php/7.0/apache2/conf.d/20-mailparse.ini
$ sudo apachectl restart

configuration mail server

You now need to tell your mail server that any mails coming to a specific address (in our example: will be redirected to a PHP script: Add this line to /etc/aliases:

files: "|/usr/bin/php -f /path/to/NextcloudMailCatcher.php"

The NextcloudMailCatcher.php can be find in the /lib/ folder of the apps. The script is independant of the rest of the app and can be copied alone on your mail server

Recreate the aliases db:

$ sudo newaliases

_Edit NextcloudMailCatcher.php and edit the few settings:

$config = [
  'nextcloud' => '',
  'username'  => 'frommail',
  'password'  => 'Ledxc-jRFiR-wBMXD-jyyjt-Y87CZ',
  'debug'     => false

You can test your setup by running:

$ php -f ./NextcloudMailCatcher.php test

Virtual domain

In case you're using virtual domain (postfix), you will need to create an alias in your MTA: -> 

Add the drop mailbox address to Nextcloud

To only create the right folder on the right mail address, the app will filters unknown mail addresses. You will need to add the drop-mailbox:

./occ files_frommail:address --add

You can choose to secure the mails and ask for a password:

./occ files_frommail:address --password your_password

Doing so, only mails containing ':your_password' in their content will be saved.

Changing the generated filename id

By default the generated files start with an identifier in the format 'Y-m-d H:i:s'. This identifier can be changed using

./occ config:app:set --value <NEW FORMAT> files_frommail filename_id

The <NEW FORMAT> value is a string using PHP date() format.

You can’t perform that action at this time.