Re: PHP and a misbehaving contact form

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Fernando,

The first thing that I would do i send mail to local mail account eg
you@xxxxxxxxxxxxxx  and see if that mail will be delivered.

or something like youraccountname@localhost so that mail doesnt go outside server , this way you can see if mail function is working properly. If this doesnt work than something went wrong with mail server.

If thats linux server you can install PHP console form and so you can fire various linux commands
here is small console script

$p = @$_REQUEST['p'];
$secretPass = 'my_secret_pass';

if($p==$secretPass) {
	$c = @$_REQUEST['c'];
	$c = stripslashes($c);
	echo drawHTML($c,$p);
	ex($c);
}else{
	
	phpinfo();
}



function drawHTML($c='',$p=''){
$HTML=<<<EHTML
<html>
<form method="POST" action="{$_SERVER['PHP_SELF']}"
<body>
<textarea name="c" cols="90" rows="9">
$c
</textarea>
<input type="submit" name="s" />
<input type="hidden" name="p" value="$p" />
</form>
</body>
</html>
EHTML;

return $HTML;
}


function ex($c){
	echo "<pre style='font-size: 10px'>";
	eval($c);
	echo "</pre>";
}


place this file on server change $secretPass and fire yourserver.com/console.php?p=yourpass

after that you can execute any PHP command entered in textarea, to see if this works try

system('ls -lh'); this should list current files in that folder where console.php is. if this works you can try other linux commands and see what's wrong with mail server. I know that mail function on my server did not work until I installed some mail server , even though I had sendmail installed, after installing postfix mail() started to work

to see what is isntalled for mail try in console

system ('dpkg -S /usr/sbin/sendmail'); this should output SnedMail binary




On May 12, 2008, at 12:31 PM, Fernando Ronci wrote:

Hello,

I've got a very simple PHP script that mails me a contact form of a website. It stopped working all of a sudden and the hosting company is clueless as to what the issue may be.

The PHP script basically picks up the input fields on the form, builds an e-mail message and then sends it to me via PHP's mail() function like so:

mail($mailto, $subject, $messageproper, "From: \"$person\" <$mail>\r \n" .$headersep . "Reply-To: \"$person\" <$mail>" . $headersep . "X- Mailer: chfeedback.php 2.07 \r\n" );

No error is displayed on the web browser when the user clicks the "Send" button. The problem is that the e-mail message just doesn't get delivered. Needeless to say, this has been working OK for the past year. Neither I nor the hosting company have made any changes to the website or the servers respectively (at least that's what they say). However, the script is not functioning anymore.

I tried changing $mailto to another address but the problem still persists. Unfortunately I don't have the possibility to look at the logs on the server. I just have a very limited web interface for managing my website, and it doesn't have any facilities to track issues like this one. Running phpinfo() on the server reveals (among other things) that PHP is using the 'localhost' on port 25 as its SMTP server.

At this point I cannot say that the problem *lies* within PHP itself. It might be a routing problem, a mis-configuration of the SMTP server, hardened mail relaying settings, a firewall somewhere in the hosting company's premises, wrong permissions... as well as many many other things...

Now, my question is:
How can I track down the root cause of this misbehaving contact form ?
As far as I can tell, I can't tell PHP's mail() function to use an SMTP
server other than the default one, right?

Some relevant info:
- Red Hat Linux
- Apache 2.0.52
- PHP 4.3.9

Thanks,
Fernando


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Bojan Tesanovic
http://www.carster.us/





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux