Want to subscribe to topics you're interested in?
Become a Member

Is it possible to disable server emails for specific vhost?

Discussion in 'Domains, DNS, Email & SSL Certificates' started by Jon Snow, Nov 15, 2020.

  1. Jon Snow

    Jon Snow Active Member

    616
    112
    43
    Jun 30, 2017
    Ratings:
    +171
    Local Time:
    6:05 AM
    Nginx 1.13.9
    MariaDB 10.1.31
    Is it possible to disable a vhost from letting its web apps send emails? Centminmod.

     
  2. eva2000

    eva2000 Administrator Staff Member

    46,649
    10,590
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +16,435
    Local Time:
    7:05 PM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    Interesting question as never looked at it from Postfix MTA mail server side. Usually your web app should support disabling email sending on the web app side. What what app is this for ?

    Wordpress can do it via plugins Disable Emails. vBulletin and Xenforo has it's own config.php options.
     
  3. Jon Snow

    Jon Snow Active Member

    616
    112
    43
    Jun 30, 2017
    Ratings:
    +171
    Local Time:
    6:05 AM
    Nginx 1.13.9
    MariaDB 10.1.31
    I know you can already do it from the web app, but I was curious if it can be done from the vhost. In a situation where your host is strict with emails and you're hosting a friend's site.
     
  4. eva2000

    eva2000 Administrator Staff Member

    46,649
    10,590
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +16,435
    Local Time:
    7:05 PM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    Highly recommend you don't :) If your friend's site is PHP based you could create a separate PHP-FPM pool and in that pool at mail() function as a disabled function PHP: Description of core php.ini directives - Manual and then set specific Nginx vhost to use that PHP-FPM instead of default one in php.conf include file.

    Code (Text):
    php_admin_value[disable_functions] = shell_exec,mail

    But then if your friend's site relies on sending emails, this will break it so probably best he be hosted on a separate server anyway

    Or other option is to modify your friend's apps to use a 3rd party SMTP server for sending emails so doesn't use your server's Postfix MTA mail server.
     
  5. Jon Snow

    Jon Snow Active Member

    616
    112
    43
    Jun 30, 2017
    Ratings:
    +171
    Local Time:
    6:05 AM
    Nginx 1.13.9
    MariaDB 10.1.31
    By "break", do you mean it'll take the whole site down like a 500 server error, or emails would just fail? The plan is to force their site to use SMTP by providing a login. If the script tries to send emails through postfix, just fail.
     
  6. eva2000

    eva2000 Administrator Staff Member

    46,649
    10,590
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +16,435
    Local Time:
    7:05 PM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    break = mail fails to send. But if it's a friend, then just ask him to use SMTP instead PHP mail - shouldn't that hard to do if it's a friend :)
     
  7. Jon Snow

    Jon Snow Active Member

    616
    112
    43
    Jun 30, 2017
    Ratings:
    +171
    Local Time:
    6:05 AM
    Nginx 1.13.9
    MariaDB 10.1.31
    Great! It's not hard and I am going to tell them to use SMTP. Not disabling it involves trust that they'd keep their promise when I prefer certainty.