473,395 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

mail() problems, how do I print out what the error is?

Hello,

I am having problems with the mail() function, but I don't know what the
problems are.

Here is a snippet of code:

$to = "jm******@comcast.net";
$from = "Ga*****@gafok.com";
$subject = "Gallery Comment";
$msg = "You have received a comment from " . $commenter_name;
$msg .= "\n\nAt index: " . $index;
$msg .= "\n\nIP address: " . $IPNumber;
$msg .= "\n\nComment: " . stripslashes($comment_text);
mail($to, $subject, $msg, "$from") or print "Cannot send mail \n";

I keep getting the "Cannot send mail" message and I want to see why. Is
there any way to see what the error really is?

thanks,

_James Luongo

Jul 16 '05 #1
3 4066
Check the [Mail Function] section of your php.ini file and make sure the
path to your mail server is correct.

Hamilton

www.laughland.biz
"the web site for web sites"

"James M. Luongo" <jm******@nospam.comcast.net> wrote in message
news:3F**************@nospam.comcast.net...
You are correct about the From: field, but that didn't solve the
problem. It's still not sending the mail and I wish to find out what
the error code or message is.

-James

Joshua Ghiloni wrote:
James M. Luongo wrote:
Hello,

I am having problems with the mail() function, but I don't know what
the problems are.

Here is a snippet of code:

$to = "jm******@comcast.net";
$from = "Ga*****@gafok.com";
$subject = "Gallery Comment";
$msg = "You have received a comment from " . $commenter_name;
$msg .= "\n\nAt index: " . $index;
$msg .= "\n\nIP address: " . $IPNumber;
$msg .= "\n\nComment: " . stripslashes($comment_text);
mail($to, $subject, $msg, "$from") or print "Cannot send mail \n";

I keep getting the "Cannot send mail" message and I want to see why.
Is there any way to see what the error really is?

thanks,

_James Luongo

Your From: header is wrong. Read up on the RFC or omit it. I do believe
that your From header should look like (untested)

$from = "From: Ga*****@gafok.com\r\n";

Jul 16 '05 #2
"James M. Luongo" <jm******@nospam.comcast.net> wrote:
I am having problems with the mail() function, but I don't know what the
problems are.

Here is a snippet of code:

$to = "jm******@comcast.net";
$from = "Ga*****@gafok.com";
$subject = "Gallery Comment";
$msg = "You have received a comment from " . $commenter_name;
$msg .= "\n\nAt index: " . $index;
$msg .= "\n\nIP address: " . $IPNumber;
$msg .= "\n\nComment: " . stripslashes($comment_text);
mail($to, $subject, $msg, "$from") or print "Cannot send mail \n";


Hi James,

The correct From header would be (and don't forget \r\n):

$from = "From: Ga*****@gafok.com\r\n";
// ..
mail($to, $subject, $msg, $from) or print "Cannot send mail \n";

If you are on Linux/Unix, check the path to sendmail in php.ini - on
Windows make sure you've set the SMTP server entry in php.ini to a valid
SMTP server.

HTH;
JOn

Jul 16 '05 #3
I'd recommend checking php.ini to see if php is writing an error log file.
If it is, check in the error log, there may be more information on the
problem in there.

"James M. Luongo" <jm******@nospam.comcast.net> wrote in message
news:3F************@nospam.comcast.net...
Hello,

I am having problems with the mail() function, but I don't know what the
problems are.

Here is a snippet of code:

$to = "jm******@comcast.net";
$from = "Ga*****@gafok.com";
$subject = "Gallery Comment";
$msg = "You have received a comment from " . $commenter_name;
$msg .= "\n\nAt index: " . $index;
$msg .= "\n\nIP address: " . $IPNumber;
$msg .= "\n\nComment: " . stripslashes($comment_text);
mail($to, $subject, $msg, "$from") or print "Cannot send mail \n";

I keep getting the "Cannot send mail" message and I want to see why. Is
there any way to see what the error really is?

thanks,

_James Luongo

Jul 16 '05 #4

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

Similar topics

8
by: Pierre Jelenc | last post by:
I use mail() for a musician's mailing list script that suddenly started having problems after many months of working flawlessly. The code fragment is: if...
1
by: Irmen de Jong | last post by:
Hi I'm trying to create e-mail content using the email.MIMEText module. It basically works, until I tried to send mail in non-ascii format. What I did, to test both iso-8859-15 and UTF-8...
7
by: Juul | last post by:
Hi, My hostingprovider just updated to PHP 4.4. Since that time I have problems using the mail() function in PHP. I can't send headers anymore and my provider don't know what's wrong. ...
8
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 -------------------------------------------------------------------------------- ...
34
by: antonyliu2002 | last post by:
I've set up the virtual smtp server on my IIS 5.1 like so: 1. Assign IP address to "All Unassigned", and listen to port 25. 2. Access Connection granted to "127.0.0.1". 3. Relay only allow...
1
by: bobano | last post by:
Hi everyone, I am writing a POP3 Client program in Perl. You connect to a POP3 Server and have a running conversation with the mail server using commands from the RFC 1939 Post Office Protocol....
3
by: Dudely | last post by:
I'm trying to debug someone else's third party code that I'm trying to install on my site. It works for him on his site, but not for me on "my" site. I've traced the problem to the mail() call....
7
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...
3
by: digitaldiva | last post by:
Hi I am new here and once upon a time I worked with Perl, now I am trying again and need some help: I wrote a Perl script a few years ago that opened an order entry TXT file and sent each...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.