Retrieve mails with smtp to store them with files_frommail

Hi community!

I’m quite new to nextcloud and just set up my own server a few days ago.

I want to download mails (especially attachements) to a specific folder with files_frommail. I followed the description written here
If I got it right, I have to place the Script “NextcloudMailCatcher.php” on a mailserver and tell it to send mails for a specific receipient to it. The script then places the mail in my nextcloud.

Unfortunately I have no acces to the mailserver, because it is from a provider.

My first approach was to use the Mail-App. But I could not get it working with our providers special settings.

So now my plan is to retrieve the mails per smtp from the mailserver and let then the php script handle the rest on the nextcloud server itself.

Is this possible? If yes, how? Or is there a better way to achieve this.

Kind regards

You could try to use fetchmail for that. Configure the mail account with it and pipe the mails to the php mailcatcher script.

Thanks for your hint. I already had a feeling, that fetchmail would be a good choice. I only wasn’t sure, if is still secure and good for using it in such an environment.

I installed it now, but I still need some help for getting it to work. I followed this guide using Webmin. But I’m not sure what good and meaningful settings would be.

For example if my constellation would be:
Remote user:

local user: ??? (maybe www-data or mail or fetchmail?) --> I use ncadmin for login, no other users are set up on the host.

What should the username in the NextcloudMailCatcher.php be like? A nextcloud user where the mails would be dropped?

There seems to be also Postfix Mail Server running. Do I need to configure it also?

In the section Add the drop mailbox address to Nextcloud of the files_frommail guide what should the drop mailbox be?

I’m not experience with mail configuration under linux. Any help would be welcome.

Kind regards

Probably it would be best to create a separate user for fetchmail.

The username in NextcloudMailCatcher.php should be the username of your Nextcloud instance where mails should be uploaded.

No need to configure Postifx, just set up fetchmail correctly to forward mails to the NextcloudMailCatcher.php script.

The mail address where you want to send your attachments that should be uploaded to Nextcloud.

Hi ptkIT, where you able to figure it out?

I have setup a mailserver with modoboa, working with an email account

I can send and receive with modoboa with no problem. I have been able to setup a nextcloud account for and on the mailserver, if I run :
php -f ./NextcloudMailCatcher.php test
Generate curl request to with username ‘test’
Content-Length: 12 (0MB)
Mail forwarded, result was [“ok”].

But now I’m lost, how to get the email account to auto-save documents to a specific folder?!

Thanks @alfred and @Berik for your contributions. Meanwhile I had and still have to deal with some other challenges of more importance. Nextcloud is a project on the side.
I will have a closer look at your suggestions in a few days and reply if this helped me.

Kind regards!