LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   making php use "mail" instead of sendmail (https://www.linuxquestions.org/questions/linux-newbie-8/making-php-use-mail-instead-of-sendmail-4175443680/)

mzzxx11 01-01-2013 09:04 AM

making php use "mail" instead of sendmail
 
Im using debian stable.

how do I get php to use "/usr/bin/mail" instead of "sendmail" to send local mail (that is, on the same machine, to a user)?

I've set sendmail_path = /usr/bin/mail
but no success.

here's the revelant part of my php.ini file:

TIA

Code:

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = me@example.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = /usr/bin/mail

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =

; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = On

; Log all mail() calls including the full path of the script, line #, to address and headers
;mail.log =


linosaurusroot 01-02-2013 04:55 AM

I doubt that is a good idea. ftp://ftp.porcupine.org/pub/security/murphy.pdf

linosaurusroot 01-02-2013 05:00 AM

Your file says
Quote:

(default: "sendmail -t -i")
which is ok for sendmail (is it -i these days and not -oi ?) but wrong for /usr/bin/mail .

jpollard 01-02-2013 08:48 AM

The problem is that mail is a mail user agent (MUA), and sendmail a mail transfer agent(MTA).

PHP is using sendmail to transfer mail from it to another (possibly remote) server. So in this structure, PHP is acting as the user agent.

One difference between MUA and MTA is that in sending mail from a user agent the destination address is expected on the command line. In the MTA it is expected as part of the input stream. That is what the -t option on the default is for, it scans the input message for To:, Cc:, and Bcc for destination addresses. The MUA expects that to be on the command line.

One advantage the sendmail used in this manner is that it is the one that determines whether a remote destination or a local one is needed. If local delivery is called for, then it goes directly to the local mail files without involving any other process.

Now that said, if you have a local mail deliver (sendmail or other) you CAN get the equivalent. What you use is "telnet localhost 25" (assuming your local mail server is using port 25 by default. This may accept the message (unless it requires a password or some extra handshaking) and blindly accept the data.

It isn't correct, as this ignores the handshaking that may be required (things like "address invalid" or "user invalid" or "reject" responses). This additional handshaking is another reason PHP uses sendmail - the appropriate handshaking is already done.

You CAN replace sendmail with something like qmail or postfix (not an endorsement - I happen to like sendmail due to its flexibility. but others do).


All times are GMT -5. The time now is 12:23 PM.