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
sendmail.php not working
Old 02-13-2007, 05:40 PM sendmail.php not working
Average Talker

Posts: 16
Name: Ryan
Trades: 0
Hello,

Quick background: I am a network admin, not a web developer. One of my clients hired a guy to create a website, which he did using PHP. Unfortunately, he ran out of time before moving to California. I published the site on a SBS 2003 server running IIS. I performed the steps necessary to allow PHP scripts to run per this article http://www.peterguy.com/php/install_IIS6.html
(this server is running Exchange). When you fill out the form and hit send, nothing happens. It does this on the live site and his 'test' server which makes we wonder if it ever worked properly at all. Here is the code from the sendmail.php. Any help would be appreciated.

<?
if(!empty($HTTP_POST_VARS['sender_mail']) || !empty($HTTP_POST_VARS['sender_message']) || !empty($HTTP_POST_VARS['sender_subject']) || !empty($HTTP_POST_VARS['sender_name']) || !empty($HTTP_POST_VARS['sender_company']) || !empty($HTTP_POST_VARS['sender_phone']) || !empty($HTTP_POST_VARS['sender_zip']) || !empty($HTTP_POST_VARS['sender_city']) || !
empty($HTTP_POST_VARS['sender_state']) || !
empty($HTTP_POST_VARS['sender_address']))
{
$to = "info@ourdomain.com";
$subject = stripslashes($HTTP_POST_VARS['sender_subject']);
$body = stripslashes($HTTP_POST_VARS['sender_message']);
$body .= "\n\n---------------------------\n";
$body .= "Mail sent by: " . $HTTP_POST_VARS['sender_name'] . " <" . $HTTP_POST_VARS['sender_mail'] . ">\n";
$body .= "Company Name: " . $HTTP_POST_VARS['sender_company'] . " \n";
$body .= "Telephone: " . $HTTP_POST_VARS['sender_phone'] . " \n";
$body .= "Address: " . $HTTP_POST_VARS['sender_address'] . " \n";
$body .= "Zip Code: " . $HTTP_POST_VARS['sender_zip'] . " \n";
$body .= "City: " . $HTTP_POST_VARS['sender_city'] . " \n";
$body .= "State: " . $HTTP_POST_VARS['sender_state'] . " \n";
$header = "From: " . $HTTP_POST_VARS['sender_name'] . " <" . $HTTP_POST_VARS['sender_mail'] . ">\n";
$header .= "Reply-To: " . $HTTP_POST_VARS['sender_name'] . " <" . $HTTP_POST_VARS['sender_mail'] . ">\n";
$header .= "X-Mailer: PHP/" . phpversion() . "\n";
$header .= "X-Priority: 1";
if(@mail($to, $subject, $body, $header))
{
echo "output=sent";
} else {
echo "output=error";
}
} else {
echo "output=error";
}
?>
rysand is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-13-2007, 08:17 PM Re: sendmail.php not working
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Well, the reason for sendmail not working is that sendmail is *nix program.
If you take a look in the php.ini file, you will see that you need to give php.ini a proper smtp server to send emails.

Take a look at this post, it explain the procedure step by step.
http://onaje.com/php/article.php4/29
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 02-13-2007, 08:47 PM Re: sendmail.php not working
Average Talker

Posts: 16
Name: Ryan
Trades: 0
Thanks for the reply but no luck. Whats weird is after filling out the form and hitting send, nothing happens...not even an error.
rysand is offline
Reply With Quote
View Public Profile
 
Old 02-13-2007, 08:51 PM Re: sendmail.php not working
Ultra Talker

Posts: 483
Trades: 0
tripy is right: you probably just need to set the PHP.INI file up correctly.

(I wrote that before I realised that you had already tried it, but anyway...)

Also, the @ symbol before the mail function call tells the function to not report any errors / warnings.

I would replace:
if(@mail($to, $subject, $body, $header))

with:
if(mail($to, $subject, $body, $header))

and see if I got any more helpful feedback...
__________________

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

Last edited by TwistMyArm; 02-13-2007 at 08:53 PM.. Reason: Just noting that I was late in my reply...
TwistMyArm is offline
Reply With Quote
View Public Profile
 
Old 02-13-2007, 09:01 PM Re: sendmail.php not working
Average Talker

Posts: 16
Name: Ryan
Trades: 0
Thanks. I will try that. My php.ini file resides in c:\php. this site had no file called php.ini. is that normal?

if it helps, the URL is www.anardash.com/brc

click on contact us.

Last edited by rysand; 02-13-2007 at 09:06 PM..
rysand is offline
Reply With Quote
View Public Profile
 
Old 02-13-2007, 09:12 PM Re: sendmail.php not working
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
Quote:
Originally Posted by rysand View Post
Thanks. I will try that. My php.ini file resides in c:\php. this site had no file called php.ini. is that normal?

if it helps, the URL is www.anardash.com/brc

click on contact us.
php.ini could be located in several places depending your your php setup. Just do a file system search for php.ini and edit the file (or files if more than one) that come up.
__________________

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
Republikin is offline
Reply With Quote
View Public Profile
 
Old 02-14-2007, 02:17 AM Re: sendmail.php not working
jito's Avatar
MY LIFE IS 'i' LIFE

Posts: 565
Name: surajit ray
Location: inside the heart of my friends
Trades: 0
Use phpinfo() to get your configaration file.
__________________
I am not smart, that's why i don't act smart


Please login or register to view this content. Registration is FREE
jito is offline
Reply With Quote
View Public Profile
 
Old 02-14-2007, 11:54 PM Re: sendmail.php not working
blackhawkpowers's Avatar
Ultra Talker

Posts: 313
Name: Dustin
Location: GA
Trades: 0
php.ini should not reside in the php dir it is normally located at c:\windows

I have written many pages that use custom mail functions and normally the issue is that the smtp server is not correctly configured. If you're running microsoft exchange I would assume it is but you can check this with a simple script.. make a new file named test.php and use the following one line....
PHP Code:
mail("myreciveing email addy""testing subject""here is the message body"from@admin.com); 
if this does work it would be very helpful if you will share either the site or the html that is posting this form with us. if it doesn't work then it's an smtp issue
__________________
A patch is a piece of software which replaces old bugs with new bugs.

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
blackhawkpowers is offline
Reply With Quote
View Public Profile Visit blackhawkpowers's homepage!
 
Old 02-15-2007, 12:23 AM Re: sendmail.php not working
Average Talker

Posts: 16
Name: Ryan
Trades: 0
thanks.

the URL is www.brctwincities.com

the page is the contact us page.

I have no idea how to run the test script.

please help.
rysand is offline
Reply With Quote
View Public Profile
 
Old 02-15-2007, 08:54 AM Re: sendmail.php not working
blackhawkpowers's Avatar
Ultra Talker

Posts: 313
Name: Dustin
Location: GA
Trades: 0
if you uploaded it to the base directory named "test.php" all you would do is go to www.brctwincities.com/test.php
the script will then execute on it's own


you should be able to change all of the HTTP_POST_VARS to _POST the HTTP_POST_VARS is NOT a superglobal and so it must be declared properly or changes written to php.ini. so the easiest way is to just user superglobals (also the most secure method)
PHP Code:
<?
if(!empty($_POST['sender_mail']) || !empty($_POST['sender_message']) || !empty($_POST['sender_subject']) || !empty($_POST['sender_name']) || !empty($_POST['sender_company']) || !empty($_POST['sender_phone']) || !empty($_POST['sender_zip']) || !empty($_POST['sender_city']) || !
empty(
$_POST['sender_state']) || !
empty(
$_POST['sender_address']))
{
$to "info@yourdomain.com";
$subject stripslashes($_POST['sender_subject']);
$body stripslashes($_POST['sender_message']);
$body .= "\n\n---------------------------\n";
$body .= "Mail sent by: " $_POST['sender_name'] . " <" $_POST['sender_mail'] . ">\n";
$body .= "Company Name: " $_POST['sender_company'] . " \n";
$body .= "Telephone: " $_POST['sender_phone'] . " \n";
$body .= "Address: " $_POST['sender_address'] . " \n";
$body .= "Zip Code: " $_POST['sender_zip'] . " \n";
$body .= "City: " $_POST['sender_city'] . " \n";
$body .= "State: " $_POST['sender_state'] . " \n";
$header "From: " $_POST['sender_name'] . " <" $_POST['sender_mail'] . ">\n";
$header .= "Reply-To: " $_POST['sender_name'] . " <" $_POST['sender_mail'] . ">\n";
$header .= "X-Mailer: PHP/" phpversion() . "\n";
$header .= "X-Priority: 1";
if(@
mail($to$subject$body$header))
{
echo 
"output=sent";
} else {
echo 
"output=error";
}
} else {
echo 
"output=error";
}
?>
Also on a sidenote whenever you guys pay someone else to redesign the site it should be done in html for buisnesses. Potential clients maynot have flash player, Google won't correctly index this site, so to get the maximum web traffic you really should have the site in a browser friendly format
__________________
A patch is a piece of software which replaces old bugs with new bugs.

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

Last edited by blackhawkpowers; 02-15-2007 at 09:11 AM..
blackhawkpowers is offline
Reply With Quote
View Public Profile Visit blackhawkpowers's homepage!
 
Old 02-15-2007, 09:20 AM Re: sendmail.php not working
Average Talker

Posts: 16
Name: Ryan
Trades: 0
Thanks a lot for all the help. I put the test file where you said, put it in the URL, I was then asked for credentials. After putting in the admin info, the page showd up and it just displayed the script test. Does this tell you anything? Again, please remember websites are not my normal deal. I do appreciate the opinion regarding how the site should have been done and will pass this off to my customer.
rysand is offline
Reply With Quote
View Public Profile
 
Old 02-15-2007, 12:30 PM Re: sendmail.php not working
metho's Avatar
Ultra Talker

Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
Trades: 0
Firstly, if the test file is just being outputted as text - you've killed php. Roll back whatever changes you made to php.ini.

If IIS has smtp installed, get it to forward all mail through exchange. If not, install it and configure it to allow localhost or 127.0.0.1 to relay and to forward all email to exchange for handling.

PHP will have a coronary trying to send email via exchange on SBS.
__________________
I do
Please login or register to view this content. Registration is FREE
based.
Spend a lot of time in
Please login or register to view this content. Registration is FREE
.
And
Please login or register to view this content. Registration is FREE
chews up the rest.
metho is offline
Reply With Quote
View Public Profile Visit metho's homepage!
 
Old 02-15-2007, 02:09 PM Re: sendmail.php not working
blackhawkpowers's Avatar
Ultra Talker

Posts: 313
Name: Dustin
Location: GA
Trades: 0
metho is absolutely correct if you saw the text in a webbrowser php is not functioning correctly and you need to address that first you should see just a white browser window when you open up that test script
__________________
A patch is a piece of software which replaces old bugs with new bugs.

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
blackhawkpowers is offline
Reply With Quote
View Public Profile Visit blackhawkpowers's homepage!
 
Old 02-15-2007, 02:29 PM Re: sendmail.php not working
Ultra Talker

Posts: 483
Trades: 0
Maybe it's not working because of the short tags? rysand: what happens if instead of:
<?

on the first line you have:
<?php

?
__________________

Please login or register to view this content. Registration is FREE
TwistMyArm is offline
Reply With Quote
View Public Profile
 
Old 02-15-2007, 04:45 PM Re: sendmail.php not working
Average Talker

Posts: 16
Name: Ryan
Trades: 0
Quote:
Originally Posted by TwistMyArm View Post
Maybe it's not working because of the short tags? rysand: what happens if instead of:
<?

on the first line you have:
<?php

?
Same thing. thanks though
rysand is offline
Reply With Quote
View Public Profile
 
Old 02-15-2007, 05:45 PM Re: sendmail.php not working
Average Talker

Posts: 16
Name: Ryan
Trades: 0
My Php File As Is:

Thanks again everyone for all the help/
Attached Files
File Type: txt PHP.TXT (47.3 KB, 3 views)

Last edited by rysand; 02-15-2007 at 05:56 PM..
rysand is offline
Reply With Quote
View Public Profile
 
Old 02-15-2007, 06:38 PM Re: sendmail.php not working
blackhawkpowers's Avatar
Ultra Talker

Posts: 313
Name: Dustin
Location: GA
Trades: 0
this should be renamed to "php.ini" not php.txt and if in the default directory should be in c:\winnt
__________________
A patch is a piece of software which replaces old bugs with new bugs.

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
blackhawkpowers is offline
Reply With Quote
View Public Profile Visit blackhawkpowers's homepage!
 
Old 02-15-2007, 06:58 PM Re: sendmail.php not working
Average Talker

Posts: 16
Name: Ryan
Trades: 0
it is named php.ini and is in the windows directory. I just named it .txt for posting purposes.
rysand is offline
Reply With Quote
View Public Profile
 
Old 02-15-2007, 08:06 PM Re: sendmail.php not working
Average Talker

Posts: 16
Name: Ryan
Trades: 0
**Update**

by altering some NTFS permissions, the script page now displays, but only shows the text.
rysand is offline
Reply With Quote
View Public Profile
 
Old 02-15-2007, 08:15 PM Re: sendmail.php not working
Average Talker

Posts: 16
Name: Ryan
Trades: 0
**Update**

The following test script worked and I received the e-mail!! THis is the closest i've come to resolving this. I do appreciate all the help.

<?php
$to = rysand@mydomain.com;
$subject = "Hi!";
$body = "Hi, How are you?";
if (@mail($to, $subject, $message)) {
echo('<p>Mail sent successfully.</p>');
} else {
echo('<p>Mail could not be sent.</p>');
}
?>

If anyone could offer anything else to get the sendmail.php form working, I would appreciate it very much.

Last edited by rysand; 02-15-2007 at 08:17 PM..
rysand is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to sendmail.php 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 1.00817 seconds with 13 queries