Nusrat Nuriyev
asked on
php doesn't work with linux sendmail utility
echo '<pre>';
system("/usr/bin/sendmail -t -i mymail@mydomail.com < /tmp/email.txt", $ret);
// Printing additional info
echo '
</pre>
<hr />Last line of the output: '
?>
Why this doesn't work on php?
If it's shared hosting, you won't have permission to run 'system' commands.
On my Ubuntu 10.04 system, 'sendmail' is in /usr/sbin/sendmail (note the 'sbin'). This works for me. I commented out your line.
<?php
echo '<pre>';
//system("/usr/bin/sendmail -t -i mymail@mydomail.com < /tmp/email.txt", $ret);
system("/usr/sbin/sendmail -t -i < emailtext.txt", $ret);
// Printing additional info
echo "$ret
</pre>
<hr />Last line of the output: ";
?>
ASKER
Well site hosting in my server.
This does not work as well.
system("/usr/sbin/sendmail -t -i nnuser@gmail.com < /tmp/email.txt", $ret);
This does not work as well.
system("/usr/sbin/sendmail
ASKER
Hey, do I need to format it in some way?
I mean does email have special format?
I mean does email have special format?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
By the way, what you are doing is almost exactly what the PHP mail() function does. It takes the information, formats it, and passes it on to 'sendmail' just like you are doing. http://us3.php.net/manual/en/function.mail.php
ASKER
we can do it with php mail() function, but it does not work as a `sendmail` system() call.
However system call for `ls` works fine.
However system call for `ls` works fine.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.