weixin_33725272 2015-11-08 00:56 采纳率: 0%
浏览 23

AJAX未发送电子邮件[重复]

This question already has answers here:
                </div>
            </div>
                    <div class="grid--cell mb0 mt4">
                        <a href="/questions/24644436/php-mail-function-doesnt-complete-sending-of-e-mail" dir="ltr">PHP mail function doesn't complete sending of e-mail</a>
                            <span class="question-originals-answer-count">
                                (26 answers)
                            </span>
                    </div>
            <div class="grid--cell mb0 mt8">Closed <span title="2015-11-08 09:36:45Z" class="relativetime">4 years ago</span>.</div>
        </div>
    </aside>

I'm trying to send a simple email from a form via jquery/AJAX. Any idea why this isn't working?

HTML:

<input id="referral-name" name="referral-name" type="text" placeholder="Your Name (First, Last)">
<input id="referral-email" name="referral-email" type="email" placeholder="Your Email">
<input id="friend-email" name="friend-email" type="email" placeholder="Your Friend's Email">
<button id="submit-referral">Send Referral</button>

Javascript:

$("#submit-referral").click(function () {

    var data = {
        referral-email: $("#referral-email").val(),
        referral-name: $("#referral-name").val(),
        friend-email: $("#friend-email").val()
    };

    $.ajax({
        type: "POST",
        url: "referral-email.php",
        data: data,
        success: function () {
            alert('Referral Sent');
        }
    });
});

PHP (named referral-email.php at the root of my folder):

<?php
if($_POST){
    $referral_name = $_POST['referral-name'];
    $referral_email = $_POST['referral-email'];
    $friend_email = $_POST['friend-email'];

//send email
    mail("my_email@email.com", "Referral Submission by ".$referral_name, $referral_name." (".$referral_email.") sent ".$friend_email." a referral.");
}
?>
</div>
  • 写回答

1条回答

      报告相同问题?

      悬赏问题

      • ¥30 如何降低hdfs中datanode的JVM内存用量
      • ¥20 SQL数据查询,子查询
      • ¥15 c++字符串分割问题
      • ¥15 vue+uniapp
      • ¥15 android freedom
      • ¥15 使用自定义的类型代替内置类型可行吗
      • ¥15 关于STM32的SPI和ENDAT接口编码器通信的问题
      • ¥15 关于#pdfbox#生成的PDF文件正常,转图片中文乱码的问题,如何解决?
      • ¥15 ADS中有关DAC控件的使用问题
      • ¥15 win11如何运行geoserver