954,591 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

php contact page

hi,

I am creating a contact us page with php and html. everything works except for the actual receiving of the email. I am using php and apache on localhost but i am connected to internet.

What i am trying to ask is: is it possible to send email using the localhost or not?

thanks

sam1
Posting Whiz
300 posts since Nov 2004
Reputation Points: 10
Solved Threads: 1
 

you have to configure smtp settings in php.ini file. If you place your file in the webserver then it is probably already configured.if you are using it in ur coimputer configure the php.ini file as:[mail function]; For Win32 only.SMTP = smtp.yourisp.com

crazynp
Junior Poster in Training
58 posts since Jan 2007
Reputation Points: 10
Solved Threads: 2
 

hi,
I am using my own computer, how do i find my smtp server. I tried google but didnt quite get it....

sam1
Posting Whiz
300 posts since Nov 2004
Reputation Points: 10
Solved Threads: 1
 

If you are using WAMP then goto config files and then goto php.ini file and edit it with above given hints. It worked for me.

crazynp
Junior Poster in Training
58 posts since Jan 2007
Reputation Points: 10
Solved Threads: 2
 

^^no i am not using WAMP, it is apache with php5. :rolleyes:

sam1
Posting Whiz
300 posts since Nov 2004
Reputation Points: 10
Solved Threads: 1
 

then no poblem just edit php.ini

crazynp
Junior Poster in Training
58 posts since Jan 2007
Reputation Points: 10
Solved Threads: 2
 

how would i do it, I tried putting in mail function mail.blueyonder.co.uk as i am using blueyonder broadband and my email address for the email. but i didnt get any results..............is that correct?

sam1
Posting Whiz
300 posts since Nov 2004
Reputation Points: 10
Solved Threads: 1
 

what error do you get?

crazynp
Junior Poster in Training
58 posts since Jan 2007
Reputation Points: 10
Solved Threads: 2
 

As i said i put blueyonder stmp and my gmail account there.... the server runs fine, but when i send the email i dont receive it in my gmail account.

sam1
Posting Whiz
300 posts since Nov 2004
Reputation Points: 10
Solved Threads: 1
 
As i said i put blueyonder stmp and my gmail account there.... the server runs fine, but when i send the email i dont receive it in my gmail account.

You dont need to put the email address in php.ini. Changing the smtp server may work fine. just try to telnet your smtp server on port 25 or 26 and if it is connected then there is no problem. You may also want to debug the code,. Can you post the code here?

crazynp
Junior Poster in Training
58 posts since Jan 2007
Reputation Points: 10
Solved Threads: 2
 

I did

telnet smtp.blueyonder.co.uk 25 and it did work but when doing telnet smtp.blueyonder.co.uk 26 it failed.

this is the code i have used :

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Contact me</title>
</head>
<body>
<?php
$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['name'];
$visitormail = $_POST['email'];
$sub = $_POST['subject'];
$notes = $_POST['textarea'];
$attn = $_POST['attn'];
?>
<?php
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
	echo "<center>";
echo "<h2>Use ''Back'' button - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted :(</h2>\n";
echo $badinput;
echo "</center>";
}
if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
}

$todayis = date("l, F j, Y, g:i a") ;

$notes = stripcslashes($notes);

$message = " $todayis [EST] \n
Subject: $sub;
Message: $notes \n
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
";

$from = "From: $visitormail\r\n";


mail("afgone@gmail.com", $sub, $notes, $message, $from);

?>

<p >
<center>
<br >
Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> )
<br >
Date: <?php echo $todayis ?>
<p>
Your Message was:
<?php $notesout = str_replace("\r", "<br/>", $notes);
echo $notesout; ?>
<p >
Your IP is : 

<?php echo $ip ?> 
Your browser is : 

<?php echo $httpagent?>

<br ><br >
<form method = "post">
<input type="button" value="Back" onClick="history.go(-1);return true;"> 
</form>
</center>
</body>
</html>
sam1
Posting Whiz
300 posts since Nov 2004
Reputation Points: 10
Solved Threads: 1
 

code looks ok, except for this:
mail("afgone@gmail.com", $sub, $notes, $message, $from); you need to look at http://php.net/manual/en/function.mail.php

$headers = "From: Me <myemailaddress.com> \r\n";
$headers .= "Bcc: Santa Clause <bigman@northpole.com>\r\n";
mail($toaddress, $subject, $messages, $headers)

You also need to need to set edit your php.ini file to use the smtp.blueyonder.co.uk for the mail function.

sn4rf3r
Junior Poster
135 posts since Sep 2006
Reputation Points: 10
Solved Threads: 2
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You