私は、VB.NET 2015を使用して自分のウェブサイトに簡単な "私に連絡"フォームを設定しようとしています。ここに私のファイルは、以下のとおりです。私のPHPフォームを使用した電子メールの送信に関する問題
PHP:
<?php
error_reporting(-1);
ini_set('display_errors', 'On');
set_error_handler("var_dump");
//if "email" variable is filled out, send email
$email = htmlspecialchars($_POST["email"], ENT_QUOTES);
$subject = htmlspecialchars($_POST["subject"], ENT_QUOTES);
$comment = htmlspecialchars($_POST["comment"], ENT_QUOTES);
$comment = str_replace("\n.", "\n..", $comment);//message can't have \n.
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Reply-To: ". $email . "\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= "From: " . $email . "\r\n";
if(mail("[email protected] ", $subject, $comment, $headers)){
//no error
exit;
}
echo "Error sending mail";
?>
活字体:上記の電子メールはちょうどこのポストのためである
module OnlinePortfolio {
export class ContactMe {
public static Email() {
$.ajax({
url: "SendMail.php",
type: "POST",
data: {
"subject": $("#subject").text(), "email": $("#email").text(), "message": $("#comment").text()
},
success: function (data, status) {
if (data === "") {
alert("Message sent successfully");
}
else {
alert("There was an issue with sending your message");
}
},
error: function (xhr, status, errorDescription) {
console.error('Something happened while sending the request: ' + status + ' - ' + errorDescription);
}
});
}
}
}
HTML
<html>
<form>
Email: <input id="email" type="text" /><br />
Subject: <input id="subject" type="text" /><br />
Message:<br />
<textarea id="comment" rows="15" cols="40"></textarea><br />
<input type="submit" value="Submit" onclick="OnlinePortfolio.ContactMe.Email()">
</form>
<html>
。私はかなりphpに新しいですが、私はいくつかの研究に基づいてこれは働いている必要があります。送信ボタンをクリックするとエラーは表示されません。また、デバッグコンソールを開いてエラーも表示されませんでした。誰かが私が電子メールを受け取っていない理由を理解するのを助けてくれますか?
事前に感謝します。
からphpmailerの(https://github.com/PHPMailer/PHPMailer))を使用してください設定.... –
@VaibhavMalveは返事をいただき、ありがとうございます。では、どうすれば電子メールを送ることができますか? – mmangual83
ライブサーバに置く必要があります。その後、SMTPだけ、あるいは単にメールのものが動作します。 –