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

Recommended Answers

All 11 Replies

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

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

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.

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

then no poblem just edit php.ini

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?

what error do you get?

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.

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?

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 ?> <br>
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>

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.