9

I am working on the contact form for the website. This contact form is realised through PHP. I was able to configure my local environment for this to work, but after deploying to production the functionality is gone.

From my point of view, the main reason why it is not working in production is that php.ini does not have the same configuration as on my local machine. Here appears couple issues:

  • I do not have any control on the production side, meaning I cannot access php.ini on the server.
  • Server has multiple domains connected to it, so changing the global configuration of php.ini would probably break something, which would be very bad.

The information I was able to find:

  • Server is Windows Server 2012 R2 v6.2 with IIS 8.5.
  • Plesk shows PHP 5.4.45 running as FastCGI application

Also one of my findings was (no surprise) to start using third-party solution like Mailgun or Mandrill. Mandrill is now plugin for Mailchimp what could be very useful as I already use Mailchimp for this project. But I do not want to go third-party as the project has a server and only missing a proper config.

UPDATE: Thanks to the answer from @oleg_neumyvakin I have found that indirect per-domain modification can be done via .user.ini configuration or if I had access to Plesk via Additional Configuration Directives field. Although the sendmail_path directive is not available for .user.ini as it can be only modified in PHP_INI_SYSTEM - global php.ini.

My question still remains open:

Community
  • 1
  • 1
alljamin
  • 719
  • 7
  • 31

1 Answers1

1

"SMTP", "smtp_port" and "sendmail_from" - are OK to be per-domain, but "sendmail_path" allowed for PHP_INI_SYSTEM only: http://php.net/manual/en/ini.list.php

You can set them via

  • /httpdocs/.user.ini file with content like:

    [PHP]
    display_errors=on
    error_reporting=32759
    log_errors=off
    max_execution_time=120
    max_input_time=90
    memory_limit=64M
    open_basedir="C:\Inetpub\vhosts\example.tld\httpdocs\;C:\Windows\Temp\"
    post_max_size=16M
    short_open_tag=off
    upload_max_filesize=16M
    error_log="C:\Inetpub\vhosts\example.tld\logs\php_errors\example.tld\php_error.log"
    
  • Plesk UI at domain's PHP settings > :

plesk per-domain PHP settings

And add necessary settings to additional directives:

plesk PHP settings

How to make sure that these changes do not affect the global PHP settings?

First of all you can set some directives to one domain and check phpinfo() for another domain. All custom PHP directives are per-directory settings and you can find them in Windows registry: PHP Windows per-directory settings

Oleg Neumyvakin
  • 7,977
  • 3
  • 44
  • 53
  • I guess that you've attached screenshots directly from the server and plesk, but I explicitly mentioned that I do not have any access/control to the production side - server. I have updated my question. – alljamin Oct 26 '16 at 06:18
  • @alljamin I've not editing any php.ini or manually change registry keys. I've change this directive via Plesk UI. – Oleg Neumyvakin Oct 26 '16 at 06:41
  • @alljamin Btw, "SMTP", "smtp_port" and "sendmail_from" - are OK to set via this directives, but "sendmail_path" will have no effect because it allowed for PHP_INI_SYSTEM only: http://php.net/manual/en/ini.list.php – Oleg Neumyvakin Oct 26 '16 at 06:48
  • But the this is that I don't have access to Plesk UI as it is on the server. – alljamin Oct 26 '16 at 09:52
  • @alljamin In this case you need .user.ini file in /httpdocs folder http://php.net/manual/en/configuration.file.per-user.php – Oleg Neumyvakin Oct 26 '16 at 10:12
  • Basically you show two similar options: one in .user.ini and another in Additional configuration directives, what I guess is the same thing. The options you show do not solve the problem because, as you mentioned yourself sendmail_path can be only configured in global php.ini. The parameters you have input in your example of .user.ini do not cover any functionality specified in my question. From your answer I can only draw a conclusion that it is not possible to do php.ini indirect configuration for parameters I am asking (sendmail in particular). – alljamin Nov 06 '16 at 04:20
  • @alljamin I'm right understand that you need sendmail_path for setup XAMPP server per domain or you just need send emails from site? – Oleg Neumyvakin Nov 06 '16 at 06:42
  • I've used XAMPP config as a working example of what I'm trying to achieve. I need to be able to send emails from the site (simple contact form - user fills in couple of input fields and clicks "send" button; the input fields contents then get send to the specified email) without touching the global php.ini - (again) no access to the backend IIS. – alljamin Nov 14 '16 at 03:49
  • @alljamin For such case you don't need sendmail_path. And I diffidently recommend use some email services like http://sendgrid.com for this(you can send email directly from PHP code without SMTP with their PHP SDK), it's free for <5000 messages and working flawless. – Oleg Neumyvakin Nov 14 '16 at 04:12