我正在使用 CodeIgniter 发送邮件。数据进入控制器,但问题在于编码。
使用的脚本:
$(".alert_button").click(function(){
var emailmy= $("#emailmy").val();
$.ajax({
url: "<?php echo site_url('home/ForgotEmailValidation'); ?>",
data: {
emailmy: emailmy
},
// context: document.body,
success: function(ret)
{
if(ret=="0")
{
$(".login_alert").show();
$(".login_ok").hide();
$('#emailmy').focus();
return false;
}
else
{
$.post("<?php echo site_url('home/ForgotPasswordMail');?>",{emailmy:emailmy},function(data){
});
$(".login_ok").show();
$(".login_alert").hide();
return true;
}
}
});
});
控制器:
//$randomString is used for send random string.
$characters = 'abcdefghijklmnopqrstuvwxyz';
$randomString = '';
for ($i = 0; $i < 20; $i++) {
$randomString .= $characters[rand(0, strlen($characters) - 1)];
}
$to = $emailMY;
$subject = "Reset your password on Pictraveler";
$message = "Thank you for using Pictraveler.com.<br/>Please go to this page to create your new password.<br/>The link will expire in 24 hours.<br/>[Reset Password]<br/><a herf='http://133.242.3.198/resetpassword/$randomString'>http://www.pictraveler.com/resetpassword?$randomString</a>";
$from = "someonelse@example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);