472,993 Members | 2,157 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,993 software developers and data experts.

Geting PHP mail to work under linux.

r0g
I'd like PHP to send mail to a local mailserver running at localhost:25
like I used to on windows. This mailserver is a dummy server which just
writes the mail to disk for unit testing and works fine when I use
thunderbird to send mail to it and used to work fine under windows
however...

It doesn't work under Ubuntu. Looking at my php.ini file I see...
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
;sendmail_from = me@example.com

; For Unix only. You may supply arguments as well (default: "sendmail
-t -i").
;sendmail_path =
Which implies you have to use sendmail. So I downloaded and installed
sendmail and it a) didn't fix this problem and b) made any scripts that
used mail lock up so I have uninstalled it again. Is there any way I can
persuade PHP to simply try to deliver the mail to my local machine's
port 25 (dummy server) like it used to in Windows XP?

Roger.
Sep 22 '08 #1
7 2579
..oO(r0g)
>I'd like PHP to send mail to a local mailserver running at localhost:25
like I used to on windows. This mailserver is a dummy server which just
writes the mail to disk for unit testing and works fine when I use
thunderbird to send mail to it and used to work fine under windows
however...

It doesn't work under Ubuntu. Looking at my php.ini file I see...
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
;sendmail_from = me@example.com

; For Unix only. You may supply arguments as well (default: "sendmail
-t -i").
;sendmail_path =
Which implies you have to use sendmail.
Or any other compatible MTA.
>So I downloaded and installed
sendmail and it a) didn't fix this problem and b) made any scripts that
used mail lock up so I have uninstalled it again. Is there any way I can
persuade PHP to simply try to deliver the mail to my local machine's
port 25 (dummy server) like it used to in Windows XP?
You could use PHPMailer to directly deliver the mail to your server via
SMTP.

Micha
Sep 22 '08 #2
On 22 Sep, 06:57, r0g <aioe....@technicalbloke.comwrote:
I'd like PHP to send mail to a local mailserver running at localhost:25
like I used to on windows. This mailserver is a dummy server which just
writes the mail to disk for unit testing and works fine when I use
thunderbird to send mail to it and used to work fine under windows
however...

It doesn't work under Ubuntu. Looking at my php.ini file I see...

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

; For Win32 only.
;sendmail_from = m...@example.com

; For Unix only. You may supply arguments as well (default: "sendmail
-t -i").
;sendmail_path =

Which implies you have to use sendmail. So I downloaded and installed
sendmail and it a) didn't fix this problem and b) made any scripts that
used mail lock up so I have uninstalled it again. Is there any way I can
persuade PHP to simply try to deliver the mail to my local machine's
port 25 (dummy server) like it used to in Windows XP?

Roger.
write a replacement for the sendmail binary:

#!/bin/bash

{
date
echo $@
cat
} >>/some/log/file

C.
Sep 22 '08 #3
r0g wrote:
I'd like PHP to send mail to a local mailserver running at localhost:25
like I used to on windows. This mailserver is a dummy server which just
writes the mail to disk for unit testing and works fine when I use
thunderbird to send mail to it and used to work fine under windows
however...

It doesn't work under Ubuntu. Looking at my php.ini file I see...
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
;sendmail_from = me@example.com

; For Unix only. You may supply arguments as well (default: "sendmail
-t -i").
;sendmail_path =
Which implies you have to use sendmail. So I downloaded and installed
sendmail and it a) didn't fix this problem and b) made any scripts that
used mail lock up so I have uninstalled it again. Is there any way I can
persuade PHP to simply try to deliver the mail to my local machine's
port 25 (dummy server) like it used to in Windows XP?

Roger.
I had trouble configuring/using 'sendmail' properly so I ended up
installing 'postfix' ('postfix' calls itself 'sendmail' so you don't
change anything in 'php.ini'). You can find your system mail in
'/var/mail/<usrname>'. You will probably need to edit the
'/etc/postfix/main.cf' file with:

myhostname = <machinehostname>
mydestination = <machinehostname>, localhost.localdomain, localhost
relayhost = <smtp-server.name.here>

You should then be able to send mail local and outbound through PHP's
mail() function. ex: <username>@<machinehostname>

--
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-
Sep 22 '08 #4
r0g
Norman Peelman wrote:
r0g wrote:
>I'd like PHP to send mail to a local mailserver running at localhost:25
like I used to on windows. This mailserver is a dummy server which just
writes the mail to disk for unit testing and works fine when I use
thunderbird to send mail to it and used to work fine under windows
however...
<snip>
>Is there any way I can
persuade PHP to simply try to deliver the mail to my local machine's
port 25 (dummy server) like it used to in Windows XP?

Roger.

I had trouble configuring/using 'sendmail' properly so I ended up
installing 'postfix' ('postfix' calls itself 'sendmail' so you don't
change anything in 'php.ini'). You can find your system mail in
'/var/mail/<usrname>'. You will probably need to edit the
'/etc/postfix/main.cf' file with:

myhostname = <machinehostname>
mydestination = <machinehostname>, localhost.localdomain, localhost
relayhost = <smtp-server.name.here>

You should then be able to send mail local and outbound through PHP's
mail() function. ex: <username>@<machinehostname>

Hi there and thanks for all you suggestions.

@Michael, PHPmailer would accompish this but I don't want to add any
extra code to my project if I can avoid it so I think I'll hav to go the
MTA route.

@C, I like the simplicity of your suggestion as all these MTA's look
unnecessarily heavy for what I want, but sadly I couldn't get it to
work, plus the unit tests I have expect separate files as generated by
the dummy SMTP server program

@Norman, I'm clearly missing something here - Whenever I install
postfix, no matter what options I choose at install time, it grabs port
25 and my dummy server can't start up. The only time it doesn't is if I
install it and select 'No configuration'. The option that looked best
was 'Internet with smarthost' which let me enter a relay server address
(in my case localhost) and, in main.cf, created exactly the settings you
describe above but it then proceeded to grab port 25 :-{ So my question
is now...

Should I plod on with the 'No configuration' install, plough though
countless forum and Usenet posts and try and make it use my local smtp
server or...

Have I got the wrong end of the stick entirely here?

I'm assuming from the settings in php .ini and what I've read that this
sendmail/postfix mechanism is file/pipe based rather than socket based
and that applications call the application, hand off the mail they want
sending to it, it then contacts the appropriate server (or relay) and
delivers it. If this is the case why is postfix grabbing port 25? And
why can't php on linux just squirt this info straight to a named port
like it can in windows? Am I missing a module or is that just not done?

Yours confused,

Roger Heathcote.
Sep 22 '08 #5
r0g wrote:
Norman Peelman wrote:
>r0g wrote:
>>I'd like PHP to send mail to a local mailserver running at localhost:25
like I used to on windows. This mailserver is a dummy server which just
writes the mail to disk for unit testing and works fine when I use
thunderbird to send mail to it and used to work fine under windows
however...
<snip>
>>Is there any way I can
persuade PHP to simply try to deliver the mail to my local machine's
port 25 (dummy server) like it used to in Windows XP?

Roger.
I had trouble configuring/using 'sendmail' properly so I ended up
installing 'postfix' ('postfix' calls itself 'sendmail' so you don't
change anything in 'php.ini'). You can find your system mail in
'/var/mail/<usrname>'. You will probably need to edit the
'/etc/postfix/main.cf' file with:

myhostname = <machinehostname>
mydestination = <machinehostname>, localhost.localdomain, localhost
relayhost = <smtp-server.name.here>

You should then be able to send mail local and outbound through PHP's
mail() function. ex: <username>@<machinehostname>


Hi there and thanks for all you suggestions.

@Michael, PHPmailer would accompish this but I don't want to add any
extra code to my project if I can avoid it so I think I'll hav to go the
MTA route.

@C, I like the simplicity of your suggestion as all these MTA's look
unnecessarily heavy for what I want, but sadly I couldn't get it to
work, plus the unit tests I have expect separate files as generated by
the dummy SMTP server program

@Norman, I'm clearly missing something here - Whenever I install
postfix, no matter what options I choose at install time, it grabs port
25 and my dummy server can't start up. The only time it doesn't is if I
install it and select 'No configuration'. The option that looked best
was 'Internet with smarthost' which let me enter a relay server address
(in my case localhost) and, in main.cf, created exactly the settings you
describe above but it then proceeded to grab port 25 :-{ So my question
is now...

Should I plod on with the 'No configuration' install, plough though
countless forum and Usenet posts and try and make it use my local smtp
server or...

Have I got the wrong end of the stick entirely here?

I'm assuming from the settings in php .ini and what I've read that this
sendmail/postfix mechanism is file/pipe based rather than socket based
and that applications call the application, hand off the mail they want
sending to it, it then contacts the appropriate server (or relay) and
delivers it. If this is the case why is postfix grabbing port 25? And
why can't php on linux just squirt this info straight to a named port
like it can in windows? Am I missing a module or is that just not done?

Yours confused,

Roger Heathcote.

I wish I knew more... the only thing I gather is that the relayhost
is for outbound (internet) traffic so maybe it is grabbing port 25 for
that. Try without and you should get local traffic only. My php.ini has
no reference to postfix and in fact is commented out as default install.
--
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-
Sep 22 '08 #6
r0g
r0g wrote:
Norman Peelman wrote:
>r0g wrote:
>>I'd like PHP to send mail to a local mailserver running at localhost:25
like I used to on windows. This mailserver is a dummy server which just
writes the mail to disk for unit testing and works fine when I use
thunderbird to send mail to it and used to work fine under windows
however...
<snip>
>>Is there any way I can
persuade PHP to simply try to deliver the mail to my local machine's
port 25 (dummy server) like it used to in Windows XP?

Roger.
I had trouble configuring/using 'sendmail' properly so I ended up
installing 'postfix' ('postfix' calls itself 'sendmail' so you don't
change anything in 'php.ini'). You can find your system mail in
'/var/mail/<usrname>'. You will probably need to edit the
'/etc/postfix/main.cf' file with:

myhostname = <machinehostname>
mydestination = <machinehostname>, localhost.localdomain, localhost
relayhost = <smtp-server.name.here>

You should then be able to send mail local and outbound through PHP's
mail() function. ex: <username>@<machinehostname>


Hi there and thanks for all you suggestions.

@Michael, PHPmailer would accompish this but I don't want to add any
extra code to my project if I can avoid it so I think I'll hav to go the
MTA route.

@C, I like the simplicity of your suggestion as all these MTA's look
unnecessarily heavy for what I want, but sadly I couldn't get it to
work, plus the unit tests I have expect separate files as generated by
the dummy SMTP server program

@Norman, I'm clearly missing something here - Whenever I install
postfix, no matter what options I choose at install time, it grabs port
25 and my dummy server can't start up. The only time it doesn't is if I
install it and select 'No configuration'. The option that looked best
was 'Internet with smarthost' which let me enter a relay server address
(in my case localhost) and, in main.cf, created exactly the settings you
describe above but it then proceeded to grab port 25 :-{ So my question
is now...

Should I plod on with the 'No configuration' install, plough though
countless forum and Usenet posts and try and make it use my local smtp
server or...

Have I got the wrong end of the stick entirely here?

I'm assuming from the settings in php .ini and what I've read that this
sendmail/postfix mechanism is file/pipe based rather than socket based
and that applications call the application, hand off the mail they want
sending to it, it then contacts the appropriate server (or relay) and
delivers it. If this is the case why is postfix grabbing port 25? And
why can't php on linux just squirt this info straight to a named port
like it can in windows? Am I missing a module or is that just not done?

Yours confused,

Roger Heathcote.

Phew Finally!

After struggling with all the various MTAs I found this wonderful little
SMTP relay program for linux... Nullmailer...
http://untroubled.org/nullmailer/

No fuss, no faff, start the install - it asks you what smtp server(s)
you want to relay your mail to, you tell it, you're done. It just sits
their pretending to be sendmail and forwarding all mail from PHP to port
25 just like I wanted :-)

Roger Heathcote.
http://untroubled.org/nullmailer/
Sep 22 '08 #7
r0g wrote:
r0g wrote:
>Norman Peelman wrote:
>>r0g wrote:
I'd like PHP to send mail to a local mailserver running at localhost:25
like I used to on windows. This mailserver is a dummy server which just
writes the mail to disk for unit testing and works fine when I use
thunderbird to send mail to it and used to work fine under windows
however...
<snip>
>>>Is there any way I can
persuade PHP to simply try to deliver the mail to my local machine's
port 25 (dummy server) like it used to in Windows XP?

Roger.
I had trouble configuring/using 'sendmail' properly so I ended up
installing 'postfix' ('postfix' calls itself 'sendmail' so you don't
change anything in 'php.ini'). You can find your system mail in
'/var/mail/<usrname>'. You will probably need to edit the
'/etc/postfix/main.cf' file with:

myhostname = <machinehostname>
mydestination = <machinehostname>, localhost.localdomain, localhost
relayhost = <smtp-server.name.here>

You should then be able to send mail local and outbound through PHP's
mail() function. ex: <username>@<machinehostname>

Hi there and thanks for all you suggestions.

@Michael, PHPmailer would accompish this but I don't want to add any
extra code to my project if I can avoid it so I think I'll hav to go the
MTA route.

@C, I like the simplicity of your suggestion as all these MTA's look
unnecessarily heavy for what I want, but sadly I couldn't get it to
work, plus the unit tests I have expect separate files as generated by
the dummy SMTP server program

@Norman, I'm clearly missing something here - Whenever I install
postfix, no matter what options I choose at install time, it grabs port
25 and my dummy server can't start up. The only time it doesn't is if I
install it and select 'No configuration'. The option that looked best
was 'Internet with smarthost' which let me enter a relay server address
(in my case localhost) and, in main.cf, created exactly the settings you
describe above but it then proceeded to grab port 25 :-{ So my question
is now...

Should I plod on with the 'No configuration' install, plough though
countless forum and Usenet posts and try and make it use my local smtp
server or...

Have I got the wrong end of the stick entirely here?

I'm assuming from the settings in php .ini and what I've read that this
sendmail/postfix mechanism is file/pipe based rather than socket based
and that applications call the application, hand off the mail they want
sending to it, it then contacts the appropriate server (or relay) and
delivers it. If this is the case why is postfix grabbing port 25? And
why can't php on linux just squirt this info straight to a named port
like it can in windows? Am I missing a module or is that just not done?

Yours confused,

Roger Heathcote.


Phew Finally!

After struggling with all the various MTAs I found this wonderful little
SMTP relay program for linux... Nullmailer...
http://untroubled.org/nullmailer/

No fuss, no faff, start the install - it asks you what smtp server(s)
you want to relay your mail to, you tell it, you're done. It just sits
their pretending to be sendmail and forwarding all mail from PHP to port
25 just like I wanted :-)

Roger Heathcote.
http://untroubled.org/nullmailer/
Glad you got something working.

--
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-
Sep 22 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Adams-Blake Co. | last post by:
This may be OT a bit, so maybe someone can point me in the right direction. I want to test a script that sends out an e-mail. I want to test it locally on my Mandrake Linux 8.2 box. It runs OK...
6
by: Tim J. | last post by:
When I send a message using the mail command in PHP some e-mail addresses somehow put two returns in place of one return, so this: $message = "Test Test2" becomes Test
3
by: Dave | last post by:
I have been reading everything i can find regarding sql mail and sql agent mail. We have a win2k server, sql 2000 and NO, NO, NO exchange server(all up to date on service packs). I have tried...
3
by: Ben Xia | last post by:
I am programming a website with php+linix+mysql+apache, I used 2 days to fighting with the php's mail() function. This is a new linux Fedora 3 system, clean install. Apache/2.0.53 (Fedora) PHP...
6
by: rodrigo guerra | last post by:
i need a exe file that will take a parameter from the command line and launch the default application that the user has to plays a video file (the param from command file). and then the exe files...
26
by: Massimo Zaccarin | last post by:
ok, I know that I have to use the System.Web.Mail.SmtpMail class, but I've read from...
8
by: Michel Posseth [MCP] | last post by:
Hi does someone has experience with this ?? i have made a lot of apps in the past that were capable of sending e-mails the server i then talked to was a Linux SMTP server and it worked great ...
14
by: luc.saffre | last post by:
Hello, the simplest way to launch the user's standard mail client from a Python program is by creating a mailto: URL and launching the webbrowser: def...
2
by: rksadhi | last post by:
/*Geting error ---object reference not set to an instance---at bold line----plz reply asap thanks in advance*/ cmd = new OleDbCommand ("SELECT e.emp_id,e.email, m.email AS Email FROM emp_details...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.