Stop applications from sending mails

Discussion in 'General' started by geekrohit, Mar 17, 2015.

  1. geekrohit

    geekrohit New Member

    Hi,

    How do I stop the PHP applications from sending mails ?
    I've tried enforcing smtp login in postfix/dovecot.
    Running ISPConfig3 on Ubuntu 12.04

    Regards
     
  2. vhacker11

    vhacker11 Member

    Hi,
    To simply disable mail() function in php you can edit your php.ini, then add the following line:
    disabled_functions = mail

    and restart your webserver (apache or nginx).

    Let me know if you need further help.
     
  3. geekrohit

    geekrohit New Member

    Could SMTP authentication be forced ?
    I'd still like to have selected apps have the capability.
     
  4. vhacker11

    vhacker11 Member

    I guess the answer is no. May be someone else could help.
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    The mail system is used by all kind off applications and cronjobs, not just php. So you cant enforce smpt-auth on the postfix sendmail wrapper. The only thing that I can think of is that you try to reconfigure postfix to send mails only locally (bind it to 127.0.0.1) so nobody can send out mails from this server. But this can onyl work if its a pure webserver and not also a mailserver. Your websites can use your external mailserver then by smtp auth only.
     
  6. geekrohit

    geekrohit New Member

    Ok, got it. Seems like a reasonable workaround.
     
  7. zayo

    zayo New Member

    i put disabled_functions = mail in php.ini, and service apache2 restart, but still i can send mail from web.
    i put disabled_functions = mail in ispconfig3 directive php snippets, but still i can send mail from web.
    in php.net disabled_functions doesn't exist.

    how it work, where is problem?
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    The settings is:

    disable_functions = mail

    and not

    disabled_functions = mail

    but this will dsallow only the php mail() function, there are other ways to send mail like the postfix sendmail warpper or smtp libraries written in php.
     
  9. zayo

    zayo New Member

    hi,
    i try change sendmail path in php.ini but phpinfo show me other config. Where can be other sendmail path config? ubuntu 14 ispconfig
     
  10. zayo

    zayo New Member

    i want put php script wrapper for control local mysql recipient send from www-data. Any idea where i connect custom script to php sendmail ? thank you
     
  11. till

    till Super Moderator Staff Member ISPConfig Developer

  12. zayo

    zayo New Member

    very nice tutorial and script. But i have one problem:
    in /etc/php5/cgi/php.ini i put line sendmail_path = /usr/local/bin/phpsendmail, and mail wrapper not work, no line writed in mail_php.log after send mail with php mail() function, phpinfo show me this:
    Loaded Configuration File /etc/php5/cgi/php.ini
    sendmail_path/usr/sbin/sendmail -t -i -fwebmaster@domain.com
    but in /etc/php5/cgi/php.ini is writed sendmail_path = /usr/local/bin/phpsendmail
    i have instaled ispconfig 3 and i never used mailbox webmaster. Its any autoconfigured, but where i find it?
     
    Last edited: Apr 6, 2015
  13. vhacker11

    vhacker11 Member

    Hi,
    If you're using apache webserver you also need to edit /etc/php5/apache2/php.ini and restart the Apache webserver to apply the changes.
     
  14. zayo

    zayo New Member

    yes i restarted apache2 x times, and still same problem
     
  15. vhacker11

    vhacker11 Member

    did you edit /etc/php5/apache2/php.ini ??
    The tutorial says, "If you use php as cgi, with suphp or as fcgi, then change the same lines in the file /etc/php5/cgi/php.ini, too."
    You seem to just have edited /etc/php5/cgi/php.ini and not /etc/php5/apache2/php.ini
    Kindly verify.
     
  16. zayo

    zayo New Member

    yes, i understand it, i changed php.ini in all folder in /etc/php5, in apache2, in cgi, in cli, and in fpm. and i restarted apache2. ok. but php function phpinfo() in web folder show me this:
    Loaded Configuration File /etc/php5/cgi/php.ini and sendmail_path/usr/sbin/sendmail -t -i -fwebmaster@domain.com but in /etc/php5/cgi/php.ini is writed sendmail_path = /usr/local/bin/phpsendmail and no other line sendmail_path
    and this i dont understand. its posible that postfix config or ispconfig overwrited it? where?
     
  17. vhacker11

    vhacker11 Member

    No. IMO neither postfix nor ISPC will overwrite it. I am sure you must have but still for confirmation, did you restart php-fpm ??
     
  18. zayo

    zayo New Member

    i restarted php5-fpm but problem still persist.
    I have already solved, with renaming files. sendmail i renamed sendmailx and phpsendmail-wrapper i renamed as sendmail and i put it on /usr/sbin now work fine sendmail wrapper. php.ini sendmail line remains a mystery.
     

Share This Page