好的,我的结果是我提交了表单,它成功地完成了所有的验证(比如,我输入了名称的数字,它捕捉到了它,但我的消息失败了)。我收到的信息是“感谢您联系我们。我们将很快与您联系。”在我的PHP页面的末尾。但我的Gmail账户没有收到电子邮件。
有一次我只是在本地调试时遇到了问题,但在我的Azure web服务器上,它起了作用。一年后,我将回到我的网站,并试图记住它是如何工作的。
我真的很难找出任何调试选项来逐步通过代码。
表格代码:
指数html
<form name="contactform" id="contactform" method="post" action="send_form_email.php">
<fieldset>
<div class="form-field">
<input name="first_name" type="text" id="first_name" placeholder="Name" value="" minlength="2" required="" aria-required="true" class="full-width">
</div>
<div class="form-field">
<input name="email" type="email" id="email" placeholder="Email" value="" required="" aria-required="true" class="full-width">
</div>
<div class="form-field">
<input name="subject" type="text" id="subject" placeholder="Subject" value="" class="full-width">
</div>
<div class="form-field">
<textarea name="comments" id="comments" placeholder="Message" rows="10" cols="50" required="" aria-required="true" class="full-width"></textarea>
</div>
<div class="form-field">
<button class="full-width btn--primary" type="submit">Submit Email</button>
<div class="submit-loader">
<div class="text-loader">Sending...</div>
<div class="s-loader">
<div class="bounce1"></div>
<div class="bounce2"></div>
<div class="bounce3"></div>
</div>
</div>
</div>
</fieldset>
</form>
这是我的PHP文件:
发送表格和电子邮件。php
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "REDACTED@gmail.com";
$email_subject = "Your email subject line";
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['first_name']) ||
!isset($_POST['email']) ||
!isset($_POST['telephone']) ||
!isset($_POST['comments'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$first_name = $_POST['first_name']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['subject']; // not required
$comments = $_POST['comments']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Subject: ".clean_string($subject)."\n";
$email_message .= "Comments: ".clean_string($comments)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your own success html here -->
Thank you for contacting us. We will be in touch with you very soon.
<?php
}
?>
Gmail可能会将你的电子邮件标记为垃圾邮件,或者完全屏蔽它。尝试使用梨邮件与SMTP:
require_once "Mail.php";
$from = '<from@gmail.com>';
$to = '<to@gmail.com>';
$subject = 'Subject';
$body = "Body";
$smtp = Mail::factory('smtp', array(
'host' => 'ssl://smtp.gmail.com',
'port' => '465',
'auth' => true,
'username' => 'johndoe@gmail.com',
'password' => 'passwordxxx'
));
$headers = array(
'From' => $from,
'To' => $to,
'Subject' => $subject
);
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo('<p>' . $mail->getMessage() . '</p>');
} else {
echo('<p>Message successfully sent!</p>');
}
/tester.java:3:错误:import java.lang.Math类型的非法启动;^Tester.java:3:错误:应输入java.lang.Math>*;^
我的adview XML文件的代码 错误:未绑定前缀。 xmlns:android=”http://schemas.android.com/apk/res/android"
我的应用程序在构建时没有任何错误,但是,当我在手机上运行它时它会停止工作,当我打开应用程序时它会停止工作,然后我决定在调试中运行它并通过logcat查看其中的错误 My build.gradle Logcat 错误(我只是采用了红色的单词) 调试错误(我只是拿了红色的单词) 我的主要活动
我在PHP codeigniter工作。当我在localhost上编辑我的文件时,它工作得很好。 但是在上传了我的网站之后,它显示了一个错误(如下所示),并且不能正常工作。 严重性:警告 消息:无法修改报头信息-已发送的报头(输出开始于 /home/innofeast014/public_html/caremykiddie.com/demo/hospital/controllers/patient
我尝试到达这个keycloakendpoint:http://10.10.10.10:8999/auth/realms/demo-realm/protocol/openid-connect/token CORS策略阻止了从来源“http://10.10.10.10:8999/auth/realms/demo-realm/protocol/openid-connect/token”访问“http:/
我在Ubuntu 18.04.5上运行。我的目录如下所示 我已经为->和->设置了符号链接,并将链接放置在目录中。当搜索终端命令时,这个目录被选中,我可以通过这种方式从任何目录成功地运行它们。