我是php新手并试图通过表单向我的Gmail发送电子邮件。点击提交,我没有在页面上看到任何错误,但我没有收到电子邮件。我从id和mail id存在,并且来自电子邮件ID在服务器上(确保不发送垃圾邮件)。
<?php
if(isset($_POST['submit'])){
$to = "existingmygamilid@gmail.com";
$subject = "Pickup Request";
$mailContent = $_POST['name'].$_POST['adress'].$_POST['mobile'].$_POST['email'].$_POST['message'];
$message = "
<html>
<head>
<title> Pickup Request</title>
</head>
<body>
<p>Hey!... You got a pickup request.</p>
";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: <existingemail@testdomain.com>' . "\r\n";
mail($to,$subject,$message,$headers);
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" class="alt" method="POST">
<div class="row uniform 50%">
<div class="6u 12u$(xsmall)">
<input name="name" placeholder="Name" type="text" />
</div>
<div class="6u$ 12u$(xsmall)">
<input name="address" placeholder="Address" type="text" />
</div>
<div class="6u 12u$(xsmall)">
<input name="mobile" placeholder="Mobile or Landline" type="text" />
</div>
<div class="6u$ 12u$(xsmall)">
<input name="email" placeholder="Email" type="email" />
</div>
<div class="12u$">
<textarea name="message" rows="6"></textarea>
</div>
</div>
<ul class="actions">
<li><input type="submit" value="Send message" /></li>
</ul>
</form>
答案 0 :(得分:1)
试试这个:
<ul class="actions">
<li><input type="submit" value="Send message" name="submit" /></li>
</ul>
给出姓名&#39;用于提交按钮。其他明智的isset($_POST['submit']
赢了工作
答案 1 :(得分:1)
试试这个
final Process p = new ProcessBuilder()
.command("repo", "forall", "-c", "pwd; git status")
// etc etc
.start();
错误
<?php
if(isset($_POST['submit'])){
$to = "existingmygamilid@gmail.com";
$subject = "Pickup Request";
$mailContent = $_POST['name'].$_POST['adress'].$_POST['mobile'].$_POST['email'].$_POST['message'];
$message = "
<html>
<head>
<title> Pickup Request</title>
</head>
<body>
<p>Hey!... You got a pickup request.</p><br><p>";
$message .= $mailContent;
$message .= "</p></body></html>";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: <existingemail@testdomain.com>' . "\r\n";
mail($to,$subject,$message,$headers);
}
?>
<form action="" class="alt" method="post">
<div class="row uniform 50%">
<div class="6u 12u$(xsmall)">
<input name="name" placeholder="Name" type="text" />
</div>
<div class="6u$ 12u$(xsmall)">
<input name="address" placeholder="Address" type="text" />
</div>
<div class="6u 12u$(xsmall)">
<input name="mobile" placeholder="Mobile or Landline" type="text" />
</div>
<div class="6u$ 12u$(xsmall)">
<input name="email" placeholder="Email" type="email" />
</div>
<div class="12u$">
<textarea name="message" rows="6"></textarea>
</div>
</div>
<ul class="actions">
<li><input type="submit" name="submit" value="Send message" /></li>
</ul>
</form>
name="submit"
)
submit
$mailContent
和</body>
)<html>
答案 2 :(得分:1)
此条件在您的代码中失败
if(isset($_POST['submit']))
您需要为提交按钮指定name属性,它才有效
<input type="submit" name="submit" value="Send message" />
答案 3 :(得分:1)
更改此行
<input type="submit" name="submit" value="Send message"/>