IMAP in Php: Marking a message unread/unseen
Question
I want to create a script in php to read al mail from a mail acount. I connect to the server, I can see the mails but went I want to seet it back to unseen I can't find a function to do this.
Solution
If I understand this page correctly:
http://www.php.net/manual/en/function.imap-body.php
You can use the FT_PEEK option to leave the message as 'unread'.
EDIT AFTER YOUR COMMENTS
Have you looked at this method?:
http://www.php.net/manual/en/function.imap-clearflag-full.php
You are able to clear the \\Seen flag.
OTHER TIPS
Simply set a link like so
<a class"setunread" href="#">Set As Unread</a>
And link it to a click function to send ajax to server via .class"setunread".
<script type="text/javascript">
$(document).ready(function() {
$(function(){
$('.setunread').click(function(){
var message_status=<?php echo $messagecall['message_status'] ;?>;
$.ajax({
type: "POST",
url: "updatemessages.php?message_status="+message_status,
dataType:"json",
success: function(datamessage) {
}
});
return false;
});
});
});
</script>
And then in Php you would connect to your database and set $_POST['message_status']
and make it secure in a variable when inserting it into the server $status=mysqli_real_escape_string($mysqli,$_POST['message_status']);
setting the status back to 0 as unseen where seen is message_status=1
. Obviously you would add more data into the server side code (Your PHP file) to select an individual message to set back to unseen but if your asking such a question, then I'd believe you to have some knowledge of how to build on this.
I know this is old, but it may well help somebody to be a bit clearer with such issues.