Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 01-01-2013, 09:04 AM   #1
Registered: Sep 2012
Posts: 78

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:


[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
;sendmail_from =

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
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
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.
Old 01-02-2013, 05:00 AM   #3
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
Your file says
(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
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,707

Rep: Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270
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


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 > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:54 PM.

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