Собственно код:
header("Content-Type: text/html; charset=utf-8");
error_reporting(0);
require_once("functions.php");
$mail_login = "***@yandex.ru";
$mail_password = "***";
$mail_imap = "{imap.yandex.ua:143/imap/novalidate-cert}";
$connection = imap_open($mail_imap, $mail_login, $mail_password);
if(!$connection){
echo("Ошибка соединения с почтой - ".$mail_login);
exit;
}else{
$msg_num = imap_num_msg($connection);
$mails_data = array();
for($i = 1; $i <= $msg_num; $i++){
$msg_header = imap_header($connection, $i);
$mails_data[$i]["time"] = time($msg_header->MailDate);
$mails_data[$i]["date"] = $msg_header->MailDate;
foreach($msg_header->from as $data){
$mails_data[$i]["from"] = $data->mailbox."@".$data->host;
}
$mails_data[$i]["title"] = get_imap_title($msg_header->subject);
$msg_structure = imap_fetchstructure($connection, $i);
$msg_body = imap_fetchbody($connection, $i, 1);
$body = "";
$recursive_data = recursive_search($msg_structure);
if($recursive_data["encoding"] == 0 || $recursive_data["encoding"] == 1){
$body = $msg_body;
}
if($recursive_data["encoding"] == 4){
$body = structure_encoding($recursive_data["encoding"], $msg_body);
}
if($recursive_data["encoding"] == 3){
$body = structure_encoding($recursive_data["encoding"], $msg_body);
}
if($recursive_data["encoding"] == 2){
$body = structure_encoding($recursive_data["encoding"], $msg_body);
}
if(!check_utf8($recursive_data["charset"])){
$body = convert_to_utf8($recursive_data["charset"], $msg_body);
}
$mails_data[$i]["body"] = base64_encode($body);
}
}
imap_close($connection);
Почта выводится из папки INBOX. Как вывести из другой папки, допустим отправленные? Спасибо!