PHP sendmail_path does not work - php

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

Related

Plesk 12 sendmail issues

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

How can I stop apache to send emails which are triggered in a php loop for testing

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.

php unable to send mail

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!

PHP Pear Mail - Include Path

I am working on a PHP project that uses PHP's built in mail function. I am adding the option to use Pear mail.
It seems that in most hosting environments, using:
require_once('Mail.php')
doesn't work which is what all of the examples I could find show. Writing the include path as:
require_once('/path/to/pear/Mail.php')
also doesn't seem to work. However, setting the include path like:
set_include_path('/path/to/pear/')
require_once('Mail.php')
does work. Because there is a configuration file in my app where this is stored and the config is used in most of my pages (not having to do with email), I am not sure if this is a good idea. My config file now has the values stored like this:
// pear smtp mail settings
set_include_path('/path/to/pear/');
define('PEAR_INCLUDE_PATH', 'Mail.php');
define('SMTP_HOST', 'ssl://smtp.gmail.com');
define('SMTP_PORT', '465');
define('SMTP_USER', 'username#gmail.com');
define('SMTP_PASS', 'password');
Is this going to create problems for me? How should I do this?
Thank you
Your pear include path should be set globally in your php.ini file -- if not, you have a broken pear/php installation.
But if you want to be extra-paranoid, you could ship a local copy of pear's Mail and Net_SMTP modules.

PHP "mail()" function sends mail from php5 cli but not when the script is run by a browser

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

Categories