The following script sends email using mail
function . But i am unable to send an email.Upon clicking submit
this gets displayed :
Warning: mail() [function.mail]: SMTP server response: 553 We do not relay non-local mail, sorry. in E:xampphtdocsfeedback.php on line 19
mail sent successfully
SCRIPT
<?php
if( isset( $_REQUEST['email'] ) ) {
$email = $_REQUEST['email'];
$subject = $_REQUEST['subject'];
$message = $_REQUEST['message'];
mail("me@gmail.com" , $subject , $message , "From:".$email );
echo "mail sent successfully";
} else {
echo "<form method = 'post' action = 'feedback.php'>
Email of sender : <input name = 'email' type = 'text' /> <br/>
Subject : <input name = 'subject' type = 'text'/> <br/>
Enter your feedback here : <textarea name = 'message' rows = 15 cols = 40 > </textarea> <br/>
<input type = 'submit'/>
</form>";
}
?>
I am using Apache as php server
Also tell why we have to write $subject
, $message
i.e with the $
sign in the mail argument , since we have declared $email
, $message
etc. , just above. Why can't we just write message , email , .. without the dollar sign?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…