IMAP in Php: message marking unread / invisible

I want to create a script in php to read mail from an email account. I connect to the server, I see the mail, but I want to see it back into the invisible. I can not find a function for this.

+2
source share
2 answers

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 β€œunread”.

EDIT AFTER YOUR COMMENTS

Have you looked at this method ?:

http://www.php.net/manual/en/function.imap-clearflag-full.php

You can clear the \\ Seen flag.

+9
source

Just set the link like this

<a class"setunread" href="#">Set As Unread</a> 

And associate it with the click function to send ajax to the 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 connect to your database and set $_POST['message_status'] and make it protected in the variable when you paste it into the server $status=mysqli_real_escape_string($mysqli,$_POST['message_status']); by setting the status to 0 as invisible, where you see message_status=1 . Obviously, you would add more data to the server-side code (your PHP file) to select an individual message to return to invisible, but if you ask such a question, I would believe that you have some information about how to build on this

I know this is old, but it can help someone to be more clear with such problems.

-1
source

Source: https://habr.com/ru/post/1438798/


All Articles