我有一个网站模板,我想在那里自定义消息发送者。我看到了这个表格来帮助实现它。
php 文件如下所示:
<?php
echo 'testing php';
$name = $_POST['name']; // contain name of person
$email = $_POST['email']; // Email address of sender
$web = $_POST['web']; // Your website URL
$body = $_POST['text']; // Your message
$receiver = "myEmail@hotmail.com" ; // hardcorde your email address here - This is the email address that all your feedbacks will be sent to
$body = "Name:{$name}\n\nWebsite :{$web}\n\nComments:{$body}";
$send = mail($receiver, 'Contact Form Submission', $body, $email);
if ($send) {
echo 'true'; //if everything is ok,always return true , else ajax submission won't work
}
?>
更新
我设法像这样调用 php 文件:
<form id="form" method="post" action="ajaxSubmit.php" >
<fieldset>
<label><input type="text" id="name" name="name" value="Name" onBlur="if(this.value=='') this.value='Name'" onFocus="if(this.value =='Name' ) this.value=''"></label>
<label><input type="text" id="email" name="email" value="Email" onBlur="if(this.value=='') this.value='Email'" onFocus="if(this.value =='Email' ) this.value=''"></label>
<label><input type="text" id="web" name="web" value="Phone" onBlur="if(this.value=='') this.value='Phone'" onFocus="if(this.value =='Phone' ) this.value=''"></label>
<label><textarea id="text" name="text" onBlur="if(this.value==''){this.value='Message'}" onFocus="if(this.value=='Message'){this.value=''}">Message</textarea></label>
<input type="reset" />
<input type="submit" />
</fieldset>
</form>
但是当我运行它时,我得到以下错误
Warning: mail() [function.mail]: SMTP server response: 550 The address is not valid. in C:\wamp\www\forSale\dataTable\ajaxSubmit.php on line 17
但后来我检查了变量的值,它们是正确的。这意味着什么?