dslf46995 2018-03-14 20:13
浏览 10
已采纳

too long

I'm new to PHP and having a hard time getting the PHP to mail when the contact form is filled out and submit is pressed. I've posted the PHP and HTML files. Any help is very much appreciated.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Jaza Solutions - Contact</title>
    <link rel = "stylesheet"
    type = "text/css"
    href = "jazasolutions.css" /> 
</head>
<body>
    <div id = "header">
        <img src="jazasolutions.png" alt = "Jaza Solutions, LLC">
    </div>
    <div id="nav">
        <ul>
            <li><a href=JazaSolutionsContact.html>Contact</a></li>
            <li><a href=JazaSolutionsAboutUs.html>About Us</a></li>
            <li><a href=JazaSolutionsCourses.html>Courses</a></li>
            <li><a href=JazaSolutions.html>Home</a></li>
        </ul>
    </div>
    <div class="sideRight">
        <p> Jaza Solutions</p>
        <p> 9818 Ushers Place </p>
        <p> Waldorf, MD 20601 </p>
        <br>
        <p>301-861-2133</p>
        <p>info@jazasolutions.com</p>
    </div>
    <div class = "main">
        <p>  Get the Management Certification you need to make the next step in your career! </p>
        <br>
        <p>SEND A MESSAGE</p>   
        <form class="contact-form" action="contactform.php" method="post">;
            <input type="text" name="name" placeholder="Full Name">
            <input type="text" name="mail" placeholder="Email">
            <input type="text" name="subject" placeholder="Subject">
            <textarea name="message" placeholder="Message"></textarea>
            <button type="submit" name="submit">SEND MAIL</button>
        </form>
    </div>
</body>
</html>   

The PHP code is posted here. This should send an email, but I can't figure out why it's not working.

<?php
if (isset($_POST['submit'])) {  
    $name = $_POST['name'];
    $subject = $_POST['subject'];
    $mailFrom = $_POST['mail'];
    $message = $_POST['message'];

    $mailTo = "pmckeown@jazasolutions.com";
    $headers = "From:  ".$mailFrom;
    $txt = "You have received an email from ".$name.".

".$message;

    mail($mailTo, $subject, $txt, $headers);
    header("Location: index.php?mailsend");
}
?> 
  • 写回答

1条回答 默认 最新

  • duanshang3230 2018-03-14 20:17
    关注

    I tried something similar a few years ago. After hours of searching I got a Tipp I'll never forget. The Mail RFC is so huge and has so many special cases that you don't do yourself a favor when you try to implement this on your own (Even if you get your Mail send it's most likely that it will be marked as spam from most of the Mail-Services out there because you missed some special handling or some tags). This becomes really funny when you try to send an attachment or even images in your mailer implementation. I'd recommend you try one of the proven Mail-Libraries for PHP like PHPMailer. You can expect that most of the common use-cases work out of the box without great problems.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度