PHP経由でWebページから収集した文字列を電子メールで送信しようとしていますが、うまくいきません。jQueryフォームの作成に関する多くの情報がありますが、単に文字列を電子メールで送信しているものは見つかりません.
ここに私がこれまでに持っているものがあります:
$('.questionFive').click(function(){
$.post("mail.php", preSubmit())
});
// this works well, and returns the string as desired.
function preSubmit(){
var optionTexts = [];
$("section").each(function(){
var h2 = $(this).find("h2").text();
optionTexts.push(h2);
$("ol li", this).each(function() { optionTexts.push($(this).text()) });
optionTexts.push("\n");
});
var optionString = optionTexts.toString();
var splitText = optionString.split(",");
alert(splitText);
return splitText;
}
// mail.php file
<?php
if (isset($_POST['mailstring']) {
$mail = $_POST['mailstring'];
mail('me@email.com', 'My Subject', $mail);
}
?>