First of this is my server configuration:
OS CloudLinux Server 6.7 (Aleksei Gubarev)
Plesk version 12.0.18 Update #65,
And now this is my problem.
I have disabled sendmail via panel, and set outoging mail limit 50 e-mail per inbox. Everything was working fine till recently when we started to have issues with mails.
Despite sendmail being disabled this works pretty good in command line
echo -e "To:test#mail.com \nSubject: Test mail from web\n\n Test mail from web via senmail\n" | sendmail -t -F root#web.domain.com
Php works fine to, via php script despite php mail function being disabled in php ini (/opt/alt/php54/etc/php.ini)
mail("test#mail.com","hello","test mail function");
And the worst thing is both of those methods ignore outgoing mail limit that is set in panel.
So basicly someone can hack one of our website and starts sending spam (which happened already).
My questions are simple. How to disable sendmail permanently and how to disable php mail function on whole server.
Ty in advance.
Here is the correct answer.
put disable_functions = "mail, sendmail, mailx" in php.ini.
If you use multiple php versions on server you have put that on every php.ini for each version.
In cloudlinux for instance location is
/opt/alt/php53/etc/php.ini
/opt/alt/php54/etc/php.ini
Related
Since upgrading to PHP7 every single script on my server using the PHP mail function no longer works :-(
At the same time, I also upgraded from Apache 2.2 to 2.4, and I have a feeling this is possibly where the problem lies.
My php.ini file contains:
sendmail_path = /usr/sbin/sendmail -t -I
Sendmail does send emails if I try from the command line, so I know it is working. I have found an error that I believe is possibly related to Apache and permissions in the exim_paniclog:
unable to set gid=995 or uid=0 (euid=0): forcing real = effective
I hope someone may have come across this problem and could possibly shed some light on it for me. Thanks in advance!
Three things to try:
1) in exim, set trusted_users = apache (or whatever your web server user is).
2) Try turning off SELinux and resarting everything. If it works now, but didn't work previously, then you'll need to either disable SELinux or learn how to configure it to allow what you need.
3) See http://blog.gaiterjones.com/send-php-mail-ubuntu-upgrade/.
Explicitly define the ITK MPM module LimitGIDRange parameter in the /etc/apache2/mods-available/mpm_prefork.conf module configuration to something like
LimitUIDRange 0 2000
Hi there I was testing php code and was sending mails to my self coz the loop was in AJAX call so i didn't find better way to test it. now i am getting thousands of emails in my gmail.
Do anyone know how to force kill the sendemail process from terminal to stop this emails send by apache.
Killing sendmail will effect other applications and your server.
A better solution would be to disable the mail function (Assuming your sending emails using PHPs mail function) only for your application.
To disable the mail function just for your application you can do this.
ini_set('disable_functions','mail'); //Place this in your PHP script
php_value disable_functions mail //Or place this in your .htaccess file
To disable the mail function for all your applications you can place the following line in your php.ini.
disable_functions = "mail"
Also, note that doing this might throw an error or warning depending on your coding.
Hope this helps.
I have a Windows 2003 server with PHP 5.24 installed on it.
I have read several posts (including the PHP manual page) on the Internet that say that sendmail_path in php.ini can be set to use a program such as Fake Sendmail which has the ability to push the mail file to my MDaemon pickup directory. I have downloaded that program and attempted to use it.
The problem is that sendmail.exe never gets executed.
sendmail_path = c:\SendMail\sendmail.exe
To verify it, I setup a simple batch file that writes to test.log when executed and changed the sendmail_path to point to the batch file. I verified the batch file does indeed create my test file when run from the command line, but when I try to send mail, the file does not get created.
sendmail_path = c:\SendMail\test.bat
The batch file never gets called.
I have tried a number of different things such as creating sendmail.exe in a path of /usr/lib/sendmail in both the c: root as well as the PHP programs folder but cannot seem to force PHP to use my file.
I have also tried putting the path name in single and double quotes, but nothing works.
In my PHP mail test I get get a fail msg and my PHP logfile shows the mail attempt to be delivered, so I know the mail process is being called.
Looking for some suggestions as to what to try next.
Gave up on trying to redirect PHP mail and just configured my servers SMTP settings to accept it. Although I had wanted to have my MDaemon mail server handle the workload, this method will suffice for the limited use it will get.
You have syntax error in php.ini! Just copy php.ini-development to php.ini and set:
SMTP =
sendmail_from =
sendmail_path = "c:\SendMail\sendmail.exe -t"
Or fix error in php.ini. Enjoy
I'm trying to set up a php script to send an email on a server with a joomla installed, I got the some script working in other project and is working fine.
I'm using this script on a landing page separate from Joomla. I had check the phpinfo and this is what it's show.
mail.add_x_header On On
mail.force_extra_parameters no value no value
mail.log no value no value
sendmail_from no value no value
sendmail_path no value no value
I'm wondering if the joomla is interfering with the mail function of php or if the function is not properly set up in php.ini
Thank you!
I am sure there are lot of plugins you can install.
Or,
Try PHPMailer. I have used it in the past. It's very easy to implement.
https://github.com/PHPMailer/PHPMailer
Hope this helps.
It means you haven't correctly setup your mail server in Joomla!
To setup the mail server go to Global Configurations > Server > Mail settings
Choose the best option for your mail settings from the dropdown and setup!
If you have a cPanel, go to Mail section and find info about your email, authentication type and more!
Hope this helps!
I have configured my server to send mail by setting "sendmail_path = "/usr/sbin/sendmail" in "/etc/php5/apache2/php.ini" and sendmail is installed on the server.
When I run this script, or any variation of it, from php5 via the cli the mail sends just fine, but when I have a browser run it, i.e. Chrome or Firefox, it fails everytime.
<?php
$to = "notreal#email.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>
I am using the "php5-cli" package for a command line interpreter.
Other PHP based web-apps that rely on the PHP "mail()" function don't send mail either.
Apache and the CLI seem to use different configurations in your setup.
Compare the configuration in /etc/php5/cli/php.ini with your Apache's php.ini. Probably something is not working with the sendmail configuration for Apache's PHP and the CLI configuration is right.
You first need to verify that current setting is the one you think it is:
var_dump(ini_get('sendmail_path'));
If it's different in web and CLI, PHP is probably different php.ini files. Run this:
phpinfo(INFO_GENERAL);
... and find this part (your values will differ from mine):
Configuration File (php.ini) Path => C:\Windows
Loaded Configuration File => C:\Program Files\PHP\php.ini
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)
That will help you identify the php.ini file you need to edit.
(Whatever, it's weird that this comes misconfigured in a Linux server.)
When you run php from cli it runs under account you logged in to linux.
When you run from Apache php runs as user that Apache runs under, usually 'nobody'
There could be several reasons why mail from 'nobody' fails - some spam filters will reject it.
Also I'm not sure what you mean by 'fails' - simply not receiving an email that you expect does not mean it wasn't sent. You should examine your mail log, usually in /var/log/maillog
and just after running your script from the browser check the latest few lines in that log,
type
# tail -20 /var/log/maillog
and see if you can spot your email being either sent or rejected. Also wait a couple minutes and check that log again - your original email may come back as bounced from some mail server, it will include explanation of why it was bounced