LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-01-2013, 09:04 AM   #1
mzzxx11
Member
 
Registered: Sep 2012
Posts: 86

Rep: Reputation: Disabled
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 =

Last edited by mzzxx11; 01-01-2013 at 09:05 AM.
 
Old 01-02-2013, 04:55 AM   #2
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
I doubt that is a good idea. ftp://ftp.porcupine.org/pub/security/murphy.pdf
 
Old 01-02-2013, 05:00 AM   #3
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
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 .
 
Old 01-02-2013, 08:48 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,908

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
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).

Last edited by jpollard; 01-02-2013 at 08:58 AM. Reason: A little additional info
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" nothing07 Programming 2 06-22-2012 02:57 PM
Postfix: how to reject incoming mail as in Sendmail's "error:nouser"? Zippy1970 Linux - Server 24 10-01-2008 08:20 AM
Communigate over Sendmail and othe "Free" variants of mail. keysorsoze Linux - Enterprise 2 11-06-2006 08:16 PM
determine Sendmail not to accept arbitrary "Mail From:" tag alext Linux - Networking 0 07-15-2006 01:25 PM
curl "incompatible pointer type" while making PHP basse- Linux - Software 2 04-15-2004 10:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration