Configure mail delivery under Debian

Hi 2 all.

I have a rather stupid question but I really got stacked.
I have a NC server in my private network that is connected using OpenVPN to a VPS acting as a gateway and frontend for it and a bunch of other staff.
I also have a mail hosting that is not related to my infrastructure (service provider) and a domain I can fully manage.

So I am trying to implement NC mail app especially - ability to send mails from the web interface.
From what I discover, the app relays on php_mail module (clearly stated in the docs) which by itself can talk to Sendmail or any “sendmail”-alike daemon configured in appropriate section of php.ini (sendmail_path = directive).

Before the mail app installation I used an sSMTP as an Sendmail substitute and it worked just fine for sending logs and other info messages to 1 user using 1 account.

Now I need to be able to send from several accounts thus different users and sSMTP will not do anymore.

As can be seen php_mail will not do anything with the mail, just pipe it to the daemon configured in php.ini file. It presents a slight problem, especially with Gmail as my reply address and bounce address (reply-to) are being changed by relaying software.

So I implemented a full-featured Sendmail install on my NC server and it works except it is trying to send mails by it’s own (that is ok, 2be expected from fresh install).
The issue with that is that traffic goes through my ISP and is presented with external ISP NAT address. I can bind Sendmail to my OpnVPN channel by use of CLIENT_OPTIONS(`Family=inet, Address=`)dnl and it may well solve the problem (just by modifying the SPF record for the domain with ip4=A.B.C.D where A.B.C.D is a VPS address) but it will not solve it for the gmail or other services I am using and have no control over SPF.

For bounce address the solution is to call a Sendmail with an -r option following with desired address. And again it’s not correct as I have several accounts across several domains and it may be only done dynamically using a webapp code. But the current version seems to not have any code for that. And even if it has it would not solve the SPF problem!

So My question is what has to be the best solution here:

  1. To install Sendmail on a VPS just relaing all mail through and figure other workarounds for “SPF-unmanagable” services?
  2. Get rid of Sendmail or/and sSMTP and use something else?
  3. Other solutions?

It seems that either I’m asking to much or am missing some key component here…

Ok, I think this is it.

The 'app.mail.transport' => 'php-mail' made me confused.


What it exactly does is instruct your PHP code to use php:mail function. And what that one does is forsing PHP to use a predefined mail program sendmail_path = /usr/sbin/sendmail -t -i from php.ini (it might be empty but will default to sendmail which in it self might be a link to something else) AND IGNORE data entered in SMTP Settings section of the user interface.

If 'app.mail.transport' => 'php-mail' is not specified in conf/config.php of Nextcloud then Mail app will execute another routine and will use data you’ve entered in SMTP Settings section of the user interface.

So in order to use a server that is defined in there one SHOULD NOT define 'app.mail.transport' => 'php-mail' in conf/config.php

I think that should be stated more clearly in admin section.