Link to home
Start Free TrialLog in
Avatar of Nusrat Nuriyev
Nusrat NuriyevFlag for Azerbaijan

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: '
?>

Open in new window


Why this doesn't work on php?
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

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: ";
?>

Open in new window

Avatar of Nusrat Nuriyev

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);
Hey, do I need to format it in some way?
I mean does email have special format?
SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial