Mail()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dave_c00
Forum Commoner
Posts: 37
Joined: Wed May 28, 2003 6:08 am

Mail()

Post by dave_c00 »

Hi,

If i want to use mail() on a web page do i need any extra stuff on my the server other than normal php.

Thanks

Dave
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

check section REQUIREMENTS on this page Mail function
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

The only thing you need is to have sendmail enabled in php.ini and sendmail_from defined and SMTP defined in php.ini.

If all that's set up then you should have no trouble, there's certainly no components to install with PHP 4+.
dave_c00
Forum Commoner
Posts: 37
Joined: Wed May 28, 2003 6:08 am

Mail()

Post by dave_c00 »

Thanks for the replies,

I do not host the site, so what do i need to ask my server company to do?

Thanks

Dave
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Have you tried using the mail() function. You didn't mention if you were getting errors and what they are.

Some hosts have the mail() function disabled for obvious reasons... If this is not the case they need to set the SMTP, and the SMTP PORT NUMBER (I can't remember the exact name for it) setting. If you have any error's and that's why you're asking please post them since it may be unrelated to the host :D
dave_c00
Forum Commoner
Posts: 37
Joined: Wed May 28, 2003 6:08 am

Post by dave_c00 »

I have the mail function amongst some other php scripting and when executed nothing happens. no error message or anything. The code is as follows;

Code: Select all

<?php
$to = "dave_c00@hotmail.com";
$subject = "New Order";
$message = "Testing";
mail($to,$subject,$message) or print "Could not send mail";
?>
Thanks

Dave


feyd | Please review how to post code using

Code: Select all

and

Code: Select all

tags. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Put:

Code: Select all

error_reporting(E_ALL);
at the top of your code and well see what happens ;-)

Run...

Code: Select all

phpinfo();
Look for disabled functions and see if it's disabled.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

these days i prefer to start debugging with:

Code: Select all

ini_set('error_reporting', E_ALL); // same as error_reporting(E_ALL);
ini_set('display_errors', TRUE); // don't know the equivalent, so it's easier to remember 2 times ini_set
Post Reply