簡體   English   中英

我的電子郵件工作流程有什么問題

[英]what wrong with my e-mail workflow

無變量的php版本有效。 但是使用變量有麻煩,所以問題應該出在php文件上:

這個對嗎?

<?php
$name=$_GET['q'];
$content=$_GET['r'];
$to      = 'mail@gmail.com';
$subject = $name;
$message = $content;
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: jcblaub@gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

html表單-問題不應該在這里

<form action="/action_page.php" class="header">
    <label for="fname">Name</label>
    <input type="text" id="fname" name="firstname" placeholder="Name ...">

    <label for="lname">E-Mail</label>
    <input type="text" id="lname" name="lastname" placeholder="E-Mail ...">

    <label for="country">Betreff - Optional</label>
    <select id="country" name="country">
        <option value="usa">-</option>
        <option value="australia">Reservierung</option>
        <option value="canada">Reperatur</option>
        <option value="usa">Fahrrad-Auswahl</option>
    </select>

    <label for="subject">Nachricht</label>
    <textarea id="subject" name="subject" placeholder="Nachricht ..." style="height:200px"></textarea>

    <input type="submit" value="Submit" id="submit">
</form>

我的JS文件-問題也不應該在這里

阿賈克斯電話

function send(str, co) {
    if (str == "") {
        document.getElementById("display").innerHTML = "";
        return;
    } else { 
        if (window.XMLHttpRequest) {
            // code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        } else {
            // code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) {
                alert('Ihre Nachricht wurde verschickt!');
            }
        };
        xmlhttp.open("GET","mail.php?q="+str + "&r=" + co ,true);
        xmlhttp.send();
    }
}

在您的php腳本中嘗試以下代碼

$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM