473,666 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2624
..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_fr om = me@example.com

; For Unix only. You may supply arguments as well (default: "sendmail
-t -i").
;sendmail_pa th =
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....@techn icalbloke.comwr ote:
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.co m

; 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 = <machinehostnam e>
mydestination = <machinehostnam e>, localhost.local domain, localhost
relayhost = <smtp-server.name.her e>

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

--
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 = <machinehostnam e>
mydestination = <machinehostnam e>, localhost.local domain, localhost
relayhost = <smtp-server.name.her e>

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

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 = <machinehostnam e>
mydestinatio n = <machinehostnam e>, localhost.local domain, localhost
relayhost = <smtp-server.name.her e>

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


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 = <machinehostnam e>
mydestinatio n = <machinehostnam e>, localhost.local domain, localhost
relayhost = <smtp-server.name.her e>

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


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
thunderbir d 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 = <machinehostnam e>
mydestinati on = <machinehostnam e>, localhost.local domain, localhost
relayhost = <smtp-server.name.her e>

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

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
unnecessaril y 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
12958
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 on my host (pair.com) but I have to upload it each time I want to test it. Is there something I need to do in order to test locally? Do I have to set up an SMTP server? Is that hard? Anything else needs to be done? CAN any of this
6
2197
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
3866
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 repeatadly for days to make this work, and have had no luck so far. 1. I have a valid profile that tests fine in sql agent and via sql
3
1688
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 4.3.11 Sendmail works fine from the linux system, I mean in linux, I can send mail out.
6
4304
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 finishes. is that possible. ? how can i do it ? links? articles ? thanks!
26
1778
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 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebmailsmtpmailclasstopic.asp: Requirements Namespace: System.Web.Mail Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family Assembly: System.Web (in System.Web.dll)
8
2842
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 Now i work in a company with a MS exchange server and would like to send some e-mails however i can`t get it to work at all error is : ( translated form the dutch language )
14
4828
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 mailto_url(to=None,subject=None,body=None,cc=None): """ encodes the content as a mailto link as described on http://www.faqs.org/rfcs/rfc2368.html
2
1540
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 e INNER JOIN emp_details m ON e.spid = m.emp_id AND e.emp_id='" + e_id + "'",conn); dr=cmd.ExecuteReader(); if(dr.Read()) { strmail=dr.ToString(); strmailto=dr.ToString(); }
0
8448
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8871
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8783
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8552
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8640
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.