Page 1 of 1

SMTP AUTH Issue with PHP Contact Form - Looking for Help!

Posted: Thu Aug 03, 2006 8:48 pm
by Kirtus
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I am working on a contact form that will send the imputted information to my client and send a response to the prospective customer... My problem is that the form is not able to authenticate within SMTP based on the code I am using.  I keep getting an error message when trying to add the $username and $password syntax . Is there a way to create a syntax that will encompass the username and password or an alternative code that I can add to my existing? Please help!!!! 
  
I have included the code below:

Code: Select all

<html>

<head>
<title>Contact</title>
<style>
BODY{color:#000000; font-size: 8pt; font-family: Verdana}
.button {background-color: rgb(128,128,128); color:#ffffff; font-size: 8pt;}
.inputc {font-size: 8pt;}
</style>
</head>

<body>

<?php


// ------------------------------------------------------------
$valid_ref1="http://name.brinkster.net/Contact.htm";
$valid_ref2="http://name.brinkster.net/Contact.htm"; 
$replyemail="admin@somethingdesign.com";//change to your email address
$host="mail.somethingdesign.com";

// ------------------------------------------------------------

//clean input in case of header injection attempts!
function clean_input_4email($value, $check_all_patterns = true)
{
 $patterns[0] = '/content-type:/';
 $patterns[1] = '/to:/';
 $patterns[2] = '/cc:/';
 $patterns[3] = '/bcc:/';
 if ($check_all_patterns)
 {
  $patterns[4] = '/\r/';
  $patterns[5] = '/\n/';
  $patterns[6] = '/%0a/';
  $patterns[7] = '/%0d/';
 }

 return preg_replace($patterns, "", strtolower($value));
}

$name = clean_input_4email($_POST["name"]);
$email = clean_input_4email($_POST["email"]);
$thesubject = clean_input_4email($_POST["thesubject"]);
$themessage = clean_input_4email($_POST["themessage"], false);

$error_msg='ERROR - not sent. Try again.';

$success_sent_msg='<p align="center"><strong> </strong></p>
                   <p align="center"><strong>Your message has been successfully sent to us<br>
                   </strong> and we will reply as soon as possible.</p>
                   <p align="center">A copy of your query has been sent to you.</p>
                   <p align="center">Thank you for contacting us.</p>';

$replymessage = "Hi $name

Thank you for your email.

We will reply to you shortly.

I hope your day is well! 

Sincerely, 

Name

Note:
Please DO NOT reply to this email.

Below is a copy of the message you submitted:
--------------------------------------------------
Subject: $thesubject
Query:
$themessage
--------------------------------------------------

Thank you";

// email variable not set - load $valid_ref1 page
if (!isset($_POST['email']))
{
 echo "<script language=\"JavaScript\"><!--\n ";
 echo "top.location.href = \"$valid_ref1\"; \n// --></script>";
 exit;
}


$ref_page=$_SERVER["HTTP_REFERER"];
$valid_referrer=0;
if($ref_page==$valid_ref1) $valid_referrer=1;
elseif($ref_page==$valid_ref2) $valid_referrer=1;
if(!$valid_referrer)
{
 echo "<script language=\"JavaScript\"><!--\n alert(\"$error_msg\");\n";
 echo "top.location.href = \"$valid_ref1\"; \n// --></script>";
 exit;
}
$themessage = "name: $name \nQuery: $themessage";

mail("$replyemail",
     "$thesubject",
     "$themessage",
     "From: $email\nReply-To: $email");
      
mail("$email",
     "Receipt: $thesubject",
     "$replymessage",
     "From: $replyemail\nReply-To: $replyemail");


echo $success_sent_msg; 
?>
</body>
</html>
-Kirtus (If you haven't realized yet - - I am a bit of a noob at this...)


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Fri Aug 04, 2006 3:04 am
by volka
phpmailer includes smtp authentication.

Re: PHP Contact Form - SMTP AUTH Issue PLZ HELP!!!

Posted: Fri Aug 04, 2006 3:07 am
by Benjamin
Kirtus wrote: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?:
Not cool man :?

Re: PHP Contact Form - SMTP AUTH Issue PLZ HELP!!!

Posted: Fri Aug 04, 2006 3:37 am
by Oren
astions wrote:
Kirtus wrote: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?:
Not cool man :?
I'll second that.
You may want to edit your post and its title dude... This way, most of the members simply won't even click on the link to see your post.