-1
所以,當我試圖通過這個代碼 這裏發送電子郵件是php文件 mail.phpPHP郵件()消息的切割一半
$cookie_name_person = "personName";
$cookie_name_email = "email";
$cookie_name_message = "emailMessage";
$cookie_name_subject = "subject";
$cookie_value_email = $_COOKIE[$cookie_name_email];
$cookie_value_message = $_COOKIE[$cookie_name_message];
$cookie_value_person = $_COOKIE[$cookie_name_person];
$cookie_value_subject = $_COOKIE[$cookie_name_subject];
$to = '[email protected]';
$subject = "${cookie_value_subject}";
$body = "От ${cookie_value_person}, \n ${cookie_value_message}";
$headers = "From: ${cookie_value_email}" . "\n";
$body = wordwrap($body, 70, "\n");
mail($to, $subject, $body, $headers);
下面是HTML文件mail.html
`
<head>
<title>NPMG Java Home Mail Form</title>
<script src="src/jquery.min.js"></script>
<script src="src/script.js"></script>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="mail.css">
</head>
<body>
<font color="white">
<form id="emailsender" method="post" name="emailForm">
<label>Име:</label>
</br>
<input type="text" id="personname"/>
</br>
<label>Email:</label>
</br>
<input type="text" id="email"/>
</br>
<label>Тема:</label>
</br>
<input type="text" id="subject"/>
</br>
<label>Съобщение:</label>
</br>
<textarea id="message" rows="10" cols="50"></textarea>
</br>
<input type="button" value="Изпрати" id="submit" onclick="sendMail()"/>
</form>
<div id="status"></div>
</font>
</body>
`
,這裏是在S從JS部分
function sendMail()
{
var email = document.getElementById("email").value;
var message = document.getElementById("message").value;
var personname = document.getElementById("personname").value;
var subject = document.getElementById("subject").value;
if(name == "" || email == "" || message == "")
{
document.getElementById("status").innerHTML = "Please fill all the gaps";
return 1;
}
var cookieNameEmail = "email";
var cookieNameMessage = "emailMessage";
var cookieNamePerson = "personName";
var cookieNameSubject = "subject";
var date = new Date();
date.setTime(date.getTime() + (60 * 1000));
var expires = "; expires=" + date.toGMTString();
document.cookie = cookieNameEmail + "=" + email + expires + "; path=/";
document.cookie = cookieNameMessage + "=" + message + expires + "; path=/";
document.cookie = cookieNamePerson + "=" + personname + expires + "; path=/";
document.cookie = cookieNameSubject + "=" + subject + expires + "; path=/";
$(document).ready(function() {
$.get('src/mail.php', function(){
window.close();
});
});
}
文本正在被從$ cookie_value_message第一個換行符後切endMail()函數。即使用\ r \ n更改了\ n,問題仍然存在
爲什麼地球上你會passi在cookie中的表單變量? –