Click here to Skip to main content
15,069,581 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have this code to send email:

XML
<html>
<body>

<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
  {
  echo "ok";
  //send email
  $email = $_REQUEST['email'] ;
  $subject = $_REQUEST['subject'] ;
  $message = $_REQUEST['message'] ;
  mail("someone@example.com", "$subject",
  $message, "From:" . $email);
   "Thank you for using our mail form";
  }
else
//if "email" is not filled out, display the form
  {?>
  <form method='post' action='webpage.php'>
  Email: <input name='email' type='text' /><br />
  Subject: <input name='subject' type='text' /><br />
  Message:<br />
  <textarea name='message' rows='15' cols='40'>
  </textarea><br />
  <input type='submit' />
  </form>
  <?php
  }
?>

</body>
</html>



this error message is displayed and email is not sent.

Warning: mail() [function.mail <http://localhost/function.mail>]: SMTP server response: 550 relay not permitted in  path 


please help.
Posted
Updated 4-Oct-11 23:39pm
v2
Comments
Bala Selvanayagam 5-Oct-11 6:18am
   
Looks your SMTP server needs authentication and the PHP mail function does not support username & pw authenticaion.

You may try

PHPMailer

Download: DOWNLOAD

Tutorial: TUTORIAL

I have checked your script and working fine, few points for you to check

1.Have you save this script file as "webpage.php" ?

2.Have you repalced "someone@example.com" with a valid email address ? - receipient email address

3.Have you ameded the php.ini file for the mail server settings SMTP & smtp_port settings ? following is my setting.

CSS
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = 10.10.27.7
; http://php.net/smtp-port
smtp_port = 25


4.If you have amended the php.ini, then did you restart your appache to pickup the new settings ?

5. your TO EMAIL ADDRESS in the form is assigned to the FROM EMAIL ADDRESS in the script ? looks not correct

6. you needs to have an echo(); function call for your text -"Thank you for using our mail form";

Hope this helps to trouble shoot
   
v5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900