I've set the "smtp" in "Config.php" in order to receive mail to my address so that all the fields filled by user gets to me, after they press "Submit" button in my "Contact.php"

Things seem to have improved a little & all I'm getting is just a "Warning message":

Warning: mail() [function.mail]: SMTP server response: 530 authentication required - for help go to http://help.yahoo.com/help/us/mail/pop/pop-11.html in C:\p3t\phpfolder\Personal Website\contact.php on line 71

Earlier I was trying to use "yahoo mail's" details but I guess I was getting this "Warning message" & hence decided to stick with "Ntlworld's" e-mail (which I've never used though & can't send an e-mail using Outlook.

My ISP is NTL at the moment & their assuming their smtp which is "smtp.ntlworld.com" & I've simply used my username & password in the "config.php" file:

<?php

// Configuration settings for My Site

// Email Settings
$site['from_name'] = 'Darsh'; // from email name
$site['from_email'] = 'darsh25@ntlworld.com'; // from email address

// Just in case we need to relay to a different server, 
// provide an option to use external mail server.
$site['smtp_mode'] = 'enable'; // enabled or disabled
$site['smtp_host'] = 'smtp.ntlworld.com';
$site['smtp_port'] = '25';
$site['smtp_username'] = 'darsh25';
?>

My updated code in "Contact.php" is now:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Personal Website</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>

<body>
<?php include("menu.inc");?>

<div id="centerContent">

<p>

<?php

// If the form has been posted, analyse it: 
if ($_POST) {
	foreach ($_POST as $field => $value) {
		$value = trim($value);
   	}

// Creating Variables
	$inquiry=$_POST['inquiry'];
	$title=$_POST['title'];
	$first_name=$_POST['first_name'];
	$last_name=$_POST['last_name'];
	$email=$_POST['email'];
	$phone=$_POST['phone'];
	$message=$_POST['message'];
	$reply=$_POST['reply'];
	$contact=$_POST['contact'];

// Create empty ERROR variables
	$error = ""; // for fields left BLANK
	$errorflag = ""; // for fields with INVALID data entered
	
// Check for field/fields that is/are left BLANK
	if (($first_name == "") || ($last_name == "") || ($email == "") || ($phone == "") || ($message == "")) {
		$error = "Please fill in all fields!";
	}
	else { 
	// Validate First Name (including ERRORS such as (1) field left BLANK (2) field with INVALID data entered 
		if (ctype_alpha($first_name) == FALSE)  {
			$error = "Please enter a valid name <span class='italic'>(Alphabets only)</span>";
			$errorflag= "first_name";
			} 
	// Validate Last Name (including ERRORS such as (1) field left BLANK (2) field with INVALID data entered 
		else if (ctype_alpha($last_name) == FALSE) {
			$error = "Please enter a valid last name <span class='italic'>(Alphabets only)</span>";
			$errorflag="last_name";
			} 
	// Validate E-mail (including ERRORS such as (1) field left BLANK (2) field with INVALID data entered 
		else if ((strpos($email, "@") == FALSE)|| 
			(strpos($email, ".") == FALSE) ||
			(strpos($email, " ") != FALSE)) {
				$error = "Please enter a valid e-mail address";
				$errorflag="email";
			} 
	// Validate Contact No. (including ERRORS such as (1) field left BLANK (2) field with INVALID data entered 
		else if (is_numeric($phone) == FALSE) {
			$error = "Please enter a valid contact number <span class='italic'>(must contain numbers only)</span>";
			$errorflag="phone";
			}
	} 
	// Confirmation Message seen AFTER filling the form and pressing "Submit" button (whether there's an error or not)
	if ($error != "") {	echo "<b><span class='colorText'>Error Occured: </b>" . $error."</span>" ; } // If there's an error along with displaying the list of flagged error/errors

// If there's NO error at all, along with displaying the filled fields
	else if (mail("darsh25@ntlworld.com", $_POST['inquiry'], stripslashes($_POST['message']), "From: " . $_POST['email'])) {
		echo "E-mail sent successfully";
		echo "<p>Thanks for your comment and time. We will be in touch with you shortly.<br/><br/>"; 
		echo "<b>Nature of Inquiry:</b> ". $inquiry . "<br/>";
		echo "<b>Title:</b> ". $title . "<br/>";
		echo "<b>First Name:</b> ". $first_name . "<br/>";
		echo "<b>Last Name:</b> ". $last_name . "<br/>";
		echo "<b>E-mail:</b> ". $email . "<br/>";
		echo "<b>Contact No.:</b> ". $phone . "<br/>";
		echo "<b>Message:</b> ". $message . "<br/>";
		echo "<b>Reply:</b> ". $reply . "<br/>";
		echo "<b>Contact Method:</b> ". $contact . "<br/></p>";
			}
else {
$error = "E-mail NOT sent";
	}
}

// DON'T KNOW WHY THERE'S "ELSE" CODE HERE
else {

	$inquiry = "";
	$title = "";
	$first_name = "";
	$last_name = "";
	$email = "";
	$phone = "";
	$message = "";
	$reply = "";
	$contact = "";
	$errorflag = "";
}

?>
</p>

<p class="first-letter">Please fill the following form in for any enquiries that you may have:</p>

<table id="contactTable">

<tr id="contactTr">
<td id="contactTd"><form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
Nature of Enquiry:</td>
<td id="contactTd"><select name="inquiry">
<option <?php if ($inquiry == "General Inquiry") echo "Selected"; ?> value = "General Inquiry">General Inquiry</option>
<option <?php if ($inquiry == "Price Quotation") echo "Selected"; ?> value = "Price Quotation">Price Quotation</option>
<option <?php if ($inquiry == "Comments") echo "Selected"; ?> value = "Comments">Comments</option>
<option <?php if ($inquiry == "Other") echo "Selected"; ?> value = "Other">Other</option>
</select></td>
</tr>

<tr id="contactTr">
<td id="contactTd">Title:</td>
<td id="contactTd"><select name="title"/>
<option <?php if ($title == "Mr") echo "Selected"; ?> value = "Mr">Mr</option>
<option <?php if ($title == "Miss") echo "Selected"; ?> value = "Miss">Miss</option>
<option <?php if ($title == "Ms") echo "Selected"; ?> value = "Ms">Ms</option>
<option <?php if ($title == "Mrs") echo "Selected"; ?> value = "Mrs">Mrs</option>
<option <?php if ($title == "Other") echo "Selected"; ?> value = "Other">Other</option>
</select></td>
</tr>

<tr id="contactTr">
<td id="contactTd"><?php if ($errorflag == "first_name") { echo "<span class='colorText'>First Name:</span>"; } 
						else { echo "First Name:"; } ?></td>
<td id="contactTd"><input type="text" size="30" maxlength="30" name="first_name" value="<?php echo $first_name; ?>"/></td>
</tr>

<tr id="contactTr">
<td id="contactTd"><?php if ($errorflag == "last_name") { echo "<span class='colorText'>Last Name:</span>"; }
						else { echo "Last name:"; } ?></td>
<td id="contactTd"><input type="text" size="30" maxlength="30" name="last_name" value="<?php echo $last_name; ?>"/></td>
</tr>

<tr id="contactTr">
<td id="contactTd"><?php if ($errorflag == "email") { echo "<span class='colorText'>E-mail:</span>"; }
						else { echo "E-mail:"; } ?></td>
<td id="contactTd"><input type="text" size="30" maxlength="30" name="email" value="<?php echo $email; ?>"/></td>
</tr>

<tr id="contactTr">
<td id="contactTd"><?php if ($errorflag == "phone") { echo "<span class='colorText'>Contact No.:</span>"; }
						else { echo "Contact No.:"; } ?></td>
<td id="contactTd"><input type="text" size="30" maxlength="20" name="phone" value="<?php echo $phone; ?>"/></td>
</tr>

<tr id="contactTr">
<td id="contactTd">Message:</td>
<td id="contactTd"><textarea rows="10" cols="50" wrap="physical" name="message"/><?php echo $message; ?>
</textarea></td>
</tr>

<tr id="contactTr">
<td id="contactTd">Reply Required:</td>
<td id="contactTd"><input type="radio" name="reply" value="Yes" checked="checked"/>Yes
<input type="radio" name="reply" value="No" <?php if ($reply="No") echo "checked='checked'"; ?>/>No</td>
</tr>

<tr id="contactTr">
<td id="contactTd">How would you like to be contacted (if required)?<br/><br/></td>
<td id="contactTd"><input type="radio" name="contact" value="Email" checked="checked"/>E-mail
<input type="radio" name="contact" value="Telephone" <?php if ($contact="Telephone") echo "checked='checked'"; ?>/>Telephone
</td>
</tr>

<tr id="contactTr">
<td id="contactTd"></td>
<td id="contactTd"><input type="reset" name="reset" value="Reset">
<input type="submit" name="submit" value="Submit"></td>
</form>
</tr>
</table>

</div>
</body>
</html>

Now after using NTL's details, why am I still getting the SAME "Warning message" related to Yahoo, while I have NOT got anything to do with "Yahoo" at all in my code. Line 71 has "darsh25@ntlworld.com" in it & has NO mention of "Yahoo" at all.

With so many tutorials over the Internet, all claiming this EASY to do, I should imagine, I'm simply making a rather simple error here. Any idea ???

As far as I'm aware the mail() functoin cannot handle SMTP servers that require authetication.

You will have to use a someone else to send your mail like PEAR's Net_SMTP package or PHPMailer.

As far as I'm aware the mail() functoin cannot handle SMTP servers that require authetication.

You will have to use a someone else to send your mail like PEAR's Net_SMTP package or PHPMailer.

Yes, you're right that mail() function cannot handle SMTP server (as I realised afterwards, after delving into it little further).

I've used the PHPMailer class & changed to "localhost" everywhere in 3 of the files (mailclass.inc, class.phpmailer.php AND config.php along with php.inc) but all in vain, since I keep on getting the error message.

Since PHPmailer class offers MORE advanced function that I don't need at this stage, isn't there easy alternative that could simply meet my basic requirement, at this stage ???

Can't I use my Yahoo's account, since that's the e-mail I most often use ???

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.