[英]Sending an email using php shows a blank page
I'm trying to collect some informations from an html form and send them to an e-mail using php. but all i get is a blank page.我正在尝试从 html 表单中收集一些信息,并使用 php 将它们发送到电子邮件。但我得到的只是一个空白页。 i looked to similar questions but i couldn't find the problem.我查看了类似的问题,但找不到问题所在。 this is my code:这是我的代码:
<?php
if(isset($_POST['submit'])){
$Fname=$_POST['First'];
$Lname=$_POST['Last'];
$email=$_POST['email'];
$code=$_POST['countryCode'];
$phone=$_POST['phone'];
$Pname=$_POST['ProjectName'];
$Ptype=$_POST['ProjectType'];
$Pdisplay=$_POST['ProjectDisplay'];
$Powner=$_POST['ProjectOwner'];
$Plang=$_POST['ProjectLang'];
$Gender=$_POST['Gender'];
$Vitess=$_POST['Vitesse'];
$Style=$_POST['Style'];
$Duration=$_POST['Duration'];
$Script=$_POST['Script'];
$Cmnt=$_POST['Cmnt'];
$to='myAdredd';
$subject='Order';
$message="First Name: ".$Fname." "."Last Name: ".$Lname." "."\n"."E-mail: ".$email."\n"."Phone: ".$code." ".$phone."\n"."Project Name: ".$Pname."\n"."Project Type: ".$Ptype."\n"."Project Display: ".$Pdisplay."\n"."Owner: ".$Powner."\n"."Language: ".$Plang."\n"."Gender Voice: ".$Gender."\n"."Vitess: ".$Vitess."\n"."Style: ".$Style."\n"."Duration: ".$Duration."\n"."Script: "."\n\n".".$Script."."Message: ".$Cmnt."\n";
$headers="From: ".$email;
if(mail($to,$subject,$message,$headers)){
echo "sent";
}else{
echo "problem ";
}
}
?>
after submitting the form i don t see neither of: "sent" or "problem"提交表格后,我没有看到:“已发送”或“问题”
the site is hosted on bluehost该网站托管在 bluehost 上
this is my first time ever using php这是我第一次使用 php
Use try
catch
for identify the error in script like-:使用try
catch
来识别脚本中的错误,例如:
<?php
try{
if(isset($_POST['submit'])){
$Fname=$_POST['First'];
$Lname=$_POST['Last'];
$email=$_POST['email'];
$code=$_POST['countryCode'];
$phone=$_POST['phone'];
$Pname=$_POST['ProjectName'];
$Ptype=$_POST['ProjectType'];
$Pdisplay=$_POST['ProjectDisplay'];
$Powner=$_POST['ProjectOwner'];
$Plang=$_POST['ProjectLang'];
$Gender=$_POST['Gender'];
$Vitess=$_POST['Vitesse'];
$Style=$_POST['Style'];
$Duration=$_POST['Duration'];
$Script=$_POST['Script'];
$Cmnt=$_POST['Cmnt'];
$to='myAdredd';
$subject='Order';
$message="First Name: ".$Fname." "."Last Name: ".$Lname." "."\n"."E-mail: ".$email."\n"."Phone: ".$code." ".$phone."\n"."Project Name: ".$Pname."\n"."Project Type: ".$Ptype."\n"."Project Display: ".$Pdisplay."\n"."Owner: ".$Powner."\n"."Language: ".$Plang."\n"."Gender Voice: ".$Gender."\n"."Vitess: ".$Vitess."\n"."Style: ".$Style."\n"."Duration: ".$Duration."\n"."Script: "."\n\n".".$Script."."Message: ".$Cmnt."\n";
$headers="From: ".$email;
if(mail($to,$subject,$message,$headers)){
echo "sent";
}else{
echo "problem ";
}
}
}
catch(Exception $e){
echo $e;
}
?>
Make sure configure SMTP configuration in php.ini file before run
mail()
.确保在运行mail()
之前在 php.ini 文件中配置 SMTP 配置。
SMTP configuration look like-: SMTP 配置如下:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.