Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP mail function not working
Old 02-26-2010, 03:54 AM PHP mail function not working
Novice Talker

Posts: 6
Trades: 0
I tried using the php mail function and it does not send any email. In my php.ini file in C:\Program Files\PHP I set SMTP to my ISP's smtp email server and port is set to 25. However, when I run phpinfo, it shows SMTP as localhost and port 25. I'm not sure why when I run phpinfo, it still says SMTP is set to localhost? How can it say this when I changed the php.ini file? Is there more than one php.ini file that I need to modify?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
ufone1234 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-26-2010, 05:48 AM Re: PHP mail function not working
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Have you restarted the php service/daemon. php.ini is only read at service start up.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-01-2010, 02:14 AM Re: PHP mail function not working
The PHP Professor

Posts: 340
Name: Alex
Location: Behind You
Trades: 0
The php.ini file can be found in two locations. If you are running cPanel you can either edit the default php.ini(Located in WHM) or override that one with a php.ini file of your choosing in your web's root directory.

Once again, this all depends on how your server was set up. Also try re-configuring PHP(if you have cpanel this is a one click step).
__________________
Go Kirby! <(" . "<) (^" . "^) (>" . ")> Talkupation!
microcolt is offline
Reply With Quote
View Public Profile Visit microcolt's homepage!
 
Old 03-06-2010, 06:50 AM Re: PHP mail function not working
Skilled Talker

Posts: 51
Name: N
Trades: 0
Step 1: copy this code and save it as mail.php and change the text like youremail@youremail.com to your actually email address etc.
Create two extra static HTML pages:

successForm.html - just a simple page saying Email was successfully sent

failureForm.html - just a simple page saying Email was unsuccessfully sent



PHP Code:
<?php
echo "<HTML><p>Please wait while we send your email...</p>
 
<head>"
;
      
$to 'youremail@youremail.com';
if (
$_SERVER['REQUEST_METHOD'] != "POST"){exit;}
while(list(
$key,$value) = each($_POST)){if(!(empty($value))){$set=1;}$message $message "$key$value\n\n";} if($set!==1){header("location: $_SERVER[HTTP_REFERER]");exit;}
$SpamErrorMessage ="No Websites URLs permitted";
if (
preg_match("/http/i","$Firstname")) {echo "$SpamErrorMessage"; exit ();}
if (
preg_match("/http/i","$Surname")) {echo "$SpamErrorMessage"; exit ();}
if (
preg_match("/http/i","$Email")) {echo "$SpamErrorMessage"; exit ();}
$message stripslashes($message);
$subject "Website Enquiry";
$headers "From: You"$_POST['email'] . "\n";
$success mail($to,$subject,$message,$headers); 
            if (
$success){echo '<meta http-equiv="refresh" content="1;URL=successForm.html">';}
            else{echo 
'<meta http-equiv="refresh" content="1;URL=failureForm.html">';}
echo 
'</head><body></body></html>';
?>
-------------------------
Step 2: In your contact page set the form action to the root file of the mail.php so if it in a file called contactus then it would be '../contactus/mail.php' etc... and set the action to post.

That's it. Hope this helps...
njccbeach9 is offline
Reply With Quote
View Public Profile
 
Old 03-10-2010, 12:30 AM Re: PHP mail function not working
Novice Talker

Posts: 6
Name: Reginald nillas
Trades: 0
I also have a problem regarding mail function. or probably there's a problem with my server coz before the mail function use to work and now it is not working in some of my webpages. it always says "undefined"


<removed>

Last edited by chrishirst; 03-10-2010 at 03:02 PM..
dacoda is offline
Reply With Quote
View Public Profile Visit dacoda's homepage!
 
Old 03-10-2010, 10:26 AM Re: PHP mail function not working
nayes84's Avatar
Extreme Talker

Latest Blog Post:
Difference between ASP And JSP
Posts: 232
Name: John
Location: Tokyo
Trades: 0
Quote:
Originally Posted by dacoda View Post
I also have a problem regarding mail function. or probably there's a problem with my server coz before the mail function use to work and now it is not working in some of my webpages. it always says "undefined"
this is probably because you changed error reporting level to display notices
http://www.php.net/manual/en/errorfu...rror-reporting
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

if(I'm("Helpful")) Add_Talkupation("nayes84");

Last edited by chrishirst; 03-10-2010 at 03:02 PM..
nayes84 is offline
Reply With Quote
View Public Profile
 
Old 03-13-2010, 11:47 AM Re: PHP mail function not working
Skilled Talker

Posts: 51
Name: N
Trades: 0
Have you tired my php mail code? It may be you wrote a mail php script in an earlier version of php and it worked for a while and as the server has updated it could be that your script might have elements that are now unsupported.
njccbeach9 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP mail function not working
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.25645 seconds with 12 queries