473,662 Members | 2,593 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mail() function problem - works in shell scripts, but not in http

Lu
Hi,

I have a redhat 9 linux machine running apache 2.0.47, mysql 4.0.15,
and php 4.3.4. I have been puzzled by this mail() problem for quite a
while, could someone please give me some hint on this?

I configured sendmail with a relay so that all outgoing mails go
through our organization's exchange mail server:
DSexchange.doma in.com. The php.ini file specified the path to
sendmail: "sendmail_p ath= /usr/sbin/sendmail -t -i".

I can send email out from shell by doing ">mail ls*******@yahoo .com".
I also tested a shell script using php mail() function:
----------------------------------------------------
#!/usr/local/php/bin/php -q
<?php
$sent=mail("ls* ******@yahoo.co m", "php email", "test this");
print "Send=$sent \n";
?>
----------------------------------------------------
This works fine too.

But when I tested the following script on the web, the email cannot be
sent out. The browser returned with "Send=". There is nothing in the
mail queue either.
----------------------------------------------------
<?php
$sent=mail("ls* ******@yahoo.co m", "php email", "test this");
print "Send=$sent \n";
?>
----------------------------------------------------

Your help is greatly appreciated.

Lu
Jul 17 '05 #1
3 2653
Lu wrote:
I also tested a shell script using php mail() function: (snip command-line php script) This works fine too.

But when I tested the following script on the web, the email cannot be
sent out.

(snip)
The default PHP configuration for my Debian machine is that php.ini for
command-line is different than php.ini for Apache 1.3.29
The first is in /etc/php4/cgi/php.ini
and the second in /etc/php4/apache/php.ini

Confirm your settings for command-line
/usr/local/php/bin/php -i | grep php\.ini

and for Apache with the output of <?php phpinfo(); ?>
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #2
Hello,

On 03/10/2004 06:13 PM, Lu wrote:
I have a redhat 9 linux machine running apache 2.0.47, mysql 4.0.15,
and php 4.3.4. I have been puzzled by this mail() problem for quite a
while, could someone please give me some hint on this?

I configured sendmail with a relay so that all outgoing mails go
through our organization's exchange mail server:
DSexchange.doma in.com. The php.ini file specified the path to
sendmail: "sendmail_p ath= /usr/sbin/sendmail -t -i".


Are you sure you can relay messages from that machine without
authentication? Usually you need to do that.

Anyway, you do not need to rely on sendmail to relay messages to a SMTP
server. You may want to try this class that comes with a wrapper
function named smtp_mail() that emulates the mail() function, except
that it lets you configure a SMTP relay server even under Linux and if
necessary authenticates to let your Exchange server relay your messages:

http://www.phpclasses.org/mimemessage

You also need this:

http://www.phpclasses.org/smtpclass


--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Jul 17 '05 #3
Lu
Thank you all so much for your help!

I finally figured it out: I was modifying the php.ini file from
/usr/local/php/lib/ direcotry, but apache needs the
/usr/local/lib/php.ini file.

Cheers!

Lu
Jul 17 '05 #4

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

Similar topics

8
4030
by: chris | last post by:
i have apache, mysql and PHP setup on my pc for development purposes and i can run the scripts fine - except when it comes to the mail() funtion what is the easiest way to set it up so i can send email's using the mail() funtion at the moment i upload it to my donain and test it but that is a pain Thanks in advance
2
3322
by: Web Master | last post by:
Hi, I am having a little issue with Jacks Form mail php script. I have installed it and configured the form to get it to work, but for some bizarre reason I have 2 issues I can't seem to debug. Issue#1: I get 2 copies of the form that gets submitted each time. Issue#2: The header does not display the "FROM" information in Outlook, but I can see the From information in my email spam filter
9
710
by: AJ | last post by:
Hi All I've got a little newsletter system that I put together for one of my customers. Basically, it's a table with firstname, lastname and e-mail address. The script then goes through the database, line by line, and sends out a personalised e-mail to the recipient. At the moment, the table is about 1500 odd recrods. When I did the send for the first time, this probably took around 30 minutes to run. Once you click on the send...
8
5464
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I debug it in PHP designer, it works with no problems, I get the test email. If
11
12309
by: Lieven | last post by:
Hey, I had a hard disc problem last week on my server. I replaced the disc and copied al the files to the new hard disc, everything works fine again except some php scripts that are using the mail() function. When executing these scripts I get this error: "500 Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request.
5
1552
by: Chris | last post by:
Apologies if this has been covered before - please slap me and point me in the right direction if so - I've limited experience of PHP so possibly missed something obvious System is a Fedora core 5 system with Apache, PHP 5.1.4 and sendmail 8.13, more or less a clean install. Sendmail has been configured to point to my ISP provider, masqerade mail and send via them. This works fine, mail comes through with the correct headers if I invoke...
4
3745
by: Gregory Bloom | last post by:
I'm running Python 2.5 under Windows. If I fire up IDLE and enter: it works like a champ, opening the page in Firefox. Same thing goes from a Windows cmd shell: it works as advertised. But if I open a cygwin bash shell and try the same thing from a python prompt, I get: Traceback (most recent call last):
7
9789
by: undbund | last post by:
Hi I am creating a newsletter system. The software should run from desktop computer (localhost) but be able to send email to anyone on the internet. Can you guys give me some ideas on how to achieve this. Thanks
3
6727
by: Max Vit | last post by:
I have come across a strange issue whilst trying to use a shell command call from Access and have spent some time trying to figure this out but can't find the cause as yet. The issue is: I need to execute a command call from within Access to execute a batch file (sample.bat). To do this, we use the Shell function, something like: Shell "cmd /c sample.bat"
0
8344
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
8857
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
8764
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
8546
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
8633
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
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1993
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1752
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.