警告:mail()[function.mail]:SMTP服务器响应:553我们不传递非本地邮件,对不起。和 [英] Warning: mail() [function.mail]: SMTP server response: 553 We do not relay non-local mail, sorry. and
问题描述
以下脚本使用 mail
函数发送电子邮件。但是我无法发送电子邮件。点击提交
将显示:
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:\xampp\htdocs\feedback.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>";
}
?>
我使用Apache作为php服务器
同时告诉我们为什么要写 $ subject
, $ message
ie由于我们已经声明了 $
登录邮件参数,因为我们已经声明了 $ email
, $ message
等,就在上面。为什么我们不能写短信,电子邮件,没有美元符号?
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?
推荐答案
-
您正在使用默认情况下附带Mercury的XAMPP,默认情况下,它不配置为将邮件发送到其他服务器。它基本上是调试。 说明确实存在进行配置要做到这一点,但Windows + Apache通常最好只是作为我的经验中的调试环境。
You're using XAMPP which by default comes with Mercury, which is not configured to send mail to a different server by default. It is basically there for debugging. Instructions do exist to configure it to do so, but Windows + Apache is generally best only as a debugging environment in my experience.
PHP变量都有$。它被称为 sigil
。它们与常量,类定义和函数区分开来。如果要分配值,然后将其发送到函数中,则需要使用变量。您可以使用 define
设置常量足够重要,但相信我,这些情况是罕见的,你一般应该避免他们。
PHP variables all have the $ before them. It's called a sigil
. It is what distinguishes them from, say, constants, class definitions, and functions. If you want to assign a value and then send it into a function, you need to use variables. You can use define
to set a constant if it is important enough, but trust me, those situations are rare and you should generally avoid them.
你也可以做但是,这样做:
You can also do this, however:
mail("me@gmail.com" ,
$_REQUEST['subject'] ,
$_REQUEST['message'] ,
"From:".$_REQUEST['email'] );
这篇关于警告:mail()[function.mail]:SMTP服务器响应:553我们不传递非本地邮件,对不起。和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!