PHP e-mail SMTP error ???

Reply

Join Date: Jan 2006
Posts: 89
Reputation: j4mes_bond25 is an unknown quantity at this point 
Solved Threads: 0
j4mes_bond25's Avatar
j4mes_bond25 j4mes_bond25 is offline Offline
Junior Poster in Training

PHP e-mail SMTP error ???

 
0
  #1
May 31st, 2006
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:

  1. <?php
  2.  
  3. // Configuration settings for My Site
  4.  
  5. // Email Settings
  6. $site['from_name'] = 'Darsh'; // from email name
  7. $site['from_email'] = 'darsh25@ntlworld.com'; // from email address
  8.  
  9. // Just in case we need to relay to a different server,
  10. // provide an option to use external mail server.
  11. $site['smtp_mode'] = 'enable'; // enabled or disabled
  12. $site['smtp_host'] = 'smtp.ntlworld.com';
  13. $site['smtp_port'] = '25';
  14. $site['smtp_username'] = 'darsh25';
  15. ?>

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

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>Personal Website</title>
  6. <link rel="stylesheet" type="text/css" href="style.css"/>
  7. </head>
  8.  
  9. <body>
  10. <?php include("menu.inc");?>
  11.  
  12. <div id="centerContent">
  13.  
  14. <p>
  15.  
  16. <?php
  17.  
  18. // If the form has been posted, analyse it:
  19. if ($_POST) {
  20. foreach ($_POST as $field => $value) {
  21. $value = trim($value);
  22. }
  23.  
  24. // Creating Variables
  25. $inquiry=$_POST['inquiry'];
  26. $title=$_POST['title'];
  27. $first_name=$_POST['first_name'];
  28. $last_name=$_POST['last_name'];
  29. $email=$_POST['email'];
  30. $phone=$_POST['phone'];
  31. $message=$_POST['message'];
  32. $reply=$_POST['reply'];
  33. $contact=$_POST['contact'];
  34.  
  35. // Create empty ERROR variables
  36. $error = ""; // for fields left BLANK
  37. $errorflag = ""; // for fields with INVALID data entered
  38.  
  39. // Check for field/fields that is/are left BLANK
  40. if (($first_name == "") || ($last_name == "") || ($email == "") || ($phone == "") || ($message == "")) {
  41. $error = "Please fill in all fields!";
  42. }
  43. else {
  44. // Validate First Name (including ERRORS such as (1) field left BLANK (2) field with INVALID data entered
  45. if (ctype_alpha($first_name) == FALSE) {
  46. $error = "Please enter a valid name <span class='italic'>(Alphabets only)</span>";
  47. $errorflag= "first_name";
  48. }
  49. // Validate Last Name (including ERRORS such as (1) field left BLANK (2) field with INVALID data entered
  50. else if (ctype_alpha($last_name) == FALSE) {
  51. $error = "Please enter a valid last name <span class='italic'>(Alphabets only)</span>";
  52. $errorflag="last_name";
  53. }
  54. // Validate E-mail (including ERRORS such as (1) field left BLANK (2) field with INVALID data entered
  55. else if ((strpos($email, "@") == FALSE)||
  56. (strpos($email, ".") == FALSE) ||
  57. (strpos($email, " ") != FALSE)) {
  58. $error = "Please enter a valid e-mail address";
  59. $errorflag="email";
  60. }
  61. // Validate Contact No. (including ERRORS such as (1) field left BLANK (2) field with INVALID data entered
  62. else if (is_numeric($phone) == FALSE) {
  63. $error = "Please enter a valid contact number <span class='italic'>(must contain numbers only)</span>";
  64. $errorflag="phone";
  65. }
  66. }
  67. // Confirmation Message seen AFTER filling the form and pressing "Submit" button (whether there's an error or not)
  68. 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
  69.  
  70. // If there's NO error at all, along with displaying the filled fields
  71. else if (mail("darsh25@ntlworld.com", $_POST['inquiry'], stripslashes($_POST['message']), "From: " . $_POST['email'])) {
  72. echo "E-mail sent successfully";
  73. echo "<p>Thanks for your comment and time. We will be in touch with you shortly.<br/><br/>";
  74. echo "<b>Nature of Inquiry:</b> ". $inquiry . "<br/>";
  75. echo "<b>Title:</b> ". $title . "<br/>";
  76. echo "<b>First Name:</b> ". $first_name . "<br/>";
  77. echo "<b>Last Name:</b> ". $last_name . "<br/>";
  78. echo "<b>E-mail:</b> ". $email . "<br/>";
  79. echo "<b>Contact No.:</b> ". $phone . "<br/>";
  80. echo "<b>Message:</b> ". $message . "<br/>";
  81. echo "<b>Reply:</b> ". $reply . "<br/>";
  82. echo "<b>Contact Method:</b> ". $contact . "<br/></p>";
  83. }
  84. else {
  85. $error = "E-mail NOT sent";
  86. }
  87. }
  88.  
  89. // DON'T KNOW WHY THERE'S "ELSE" CODE HERE
  90. else {
  91.  
  92. $inquiry = "";
  93. $title = "";
  94. $first_name = "";
  95. $last_name = "";
  96. $email = "";
  97. $phone = "";
  98. $message = "";
  99. $reply = "";
  100. $contact = "";
  101. $errorflag = "";
  102. }
  103.  
  104. ?>
  105. </p>
  106.  
  107. <p class="first-letter">Please fill the following form in for any enquiries that you may have:</p>
  108.  
  109. <table id="contactTable">
  110.  
  111. <tr id="contactTr">
  112. <td id="contactTd"><form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
  113. Nature of Enquiry:</td>
  114. <td id="contactTd"><select name="inquiry">
  115. <option <?php if ($inquiry == "General Inquiry") echo "Selected"; ?> value = "General Inquiry">General Inquiry</option>
  116. <option <?php if ($inquiry == "Price Quotation") echo "Selected"; ?> value = "Price Quotation">Price Quotation</option>
  117. <option <?php if ($inquiry == "Comments") echo "Selected"; ?> value = "Comments">Comments</option>
  118. <option <?php if ($inquiry == "Other") echo "Selected"; ?> value = "Other">Other</option>
  119. </select></td>
  120. </tr>
  121.  
  122. <tr id="contactTr">
  123. <td id="contactTd">Title:</td>
  124. <td id="contactTd"><select name="title"/>
  125. <option <?php if ($title == "Mr") echo "Selected"; ?> value = "Mr">Mr</option>
  126. <option <?php if ($title == "Miss") echo "Selected"; ?> value = "Miss">Miss</option>
  127. <option <?php if ($title == "Ms") echo "Selected"; ?> value = "Ms">Ms</option>
  128. <option <?php if ($title == "Mrs") echo "Selected"; ?> value = "Mrs">Mrs</option>
  129. <option <?php if ($title == "Other") echo "Selected"; ?> value = "Other">Other</option>
  130. </select></td>
  131. </tr>
  132.  
  133. <tr id="contactTr">
  134. <td id="contactTd"><?php if ($errorflag == "first_name") { echo "<span class='colorText'>First Name:</span>"; }
  135. else { echo "First Name:"; } ?></td>
  136. <td id="contactTd"><input type="text" size="30" maxlength="30" name="first_name" value="<?php echo $first_name; ?>"/></td>
  137. </tr>
  138.  
  139. <tr id="contactTr">
  140. <td id="contactTd"><?php if ($errorflag == "last_name") { echo "<span class='colorText'>Last Name:</span>"; }
  141. else { echo "Last name:"; } ?></td>
  142. <td id="contactTd"><input type="text" size="30" maxlength="30" name="last_name" value="<?php echo $last_name; ?>"/></td>
  143. </tr>
  144.  
  145. <tr id="contactTr">
  146. <td id="contactTd"><?php if ($errorflag == "email") { echo "<span class='colorText'>E-mail:</span>"; }
  147. else { echo "E-mail:"; } ?></td>
  148. <td id="contactTd"><input type="text" size="30" maxlength="30" name="email" value="<?php echo $email; ?>"/></td>
  149. </tr>
  150.  
  151. <tr id="contactTr">
  152. <td id="contactTd"><?php if ($errorflag == "phone") { echo "<span class='colorText'>Contact No.:</span>"; }
  153. else { echo "Contact No.:"; } ?></td>
  154. <td id="contactTd"><input type="text" size="30" maxlength="20" name="phone" value="<?php echo $phone; ?>"/></td>
  155. </tr>
  156.  
  157. <tr id="contactTr">
  158. <td id="contactTd">Message:</td>
  159. <td id="contactTd"><textarea rows="10" cols="50" wrap="physical" name="message"/><?php echo $message; ?>
  160. </textarea></td>
  161. </tr>
  162.  
  163. <tr id="contactTr">
  164. <td id="contactTd">Reply Required:</td>
  165. <td id="contactTd"><input type="radio" name="reply" value="Yes" checked="checked"/>Yes
  166. <input type="radio" name="reply" value="No" <?php if ($reply="No") echo "checked='checked'"; ?>/>No</td>
  167. </tr>
  168.  
  169. <tr id="contactTr">
  170. <td id="contactTd">How would you like to be contacted (if required)?<br/><br/></td>
  171. <td id="contactTd"><input type="radio" name="contact" value="Email" checked="checked"/>E-mail
  172. <input type="radio" name="contact" value="Telephone" <?php if ($contact="Telephone") echo "checked='checked'"; ?>/>Telephone
  173. </td>
  174. </tr>
  175.  
  176. <tr id="contactTr">
  177. <td id="contactTd"></td>
  178. <td id="contactTd"><input type="reset" name="reset" value="Reset">
  179. <input type="submit" name="submit" value="Submit"></td>
  180. </form>
  181. </tr>
  182. </table>
  183.  
  184. </div>
  185. </body>
  186. </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 ???
Nope, I'm NOT God, but I'm British (which is the next best thing ;)
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 32
Reputation: BlazingWolf is an unknown quantity at this point 
Solved Threads: 1
BlazingWolf BlazingWolf is offline Offline
Light Poster

Re: PHP e-mail SMTP error ???

 
0
  #2
May 31st, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 89
Reputation: j4mes_bond25 is an unknown quantity at this point 
Solved Threads: 0
j4mes_bond25's Avatar
j4mes_bond25 j4mes_bond25 is offline Offline
Junior Poster in Training

Re: PHP e-mail SMTP error ???

 
0
  #3
May 31st, 2006
Originally Posted by BlazingWolf
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 ???
Nope, I'm NOT God, but I'm British (which is the next best thing ;)
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC