Код: Выделить всё
function gmail($mail, $password, $from='', $partno='2.1'){
$mbox = imap_open('{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX', $mail, $password) or die('Failed with error: '.imap_last_error());
$messages = imap_sort($mbox, SORTDATE, 1);
foreach ($messages as $message) {
$header = imap_header($mbox, $message);
if ($from=='')
$msg[] = $message;
else if ($from==$header->fromaddress)
$msg[] = $message;
}
$sss = imap_fetchbody($mbox, $msg[0], $partno);
imap_close($mbox);
return $sss;
}
Пример:
Код: Выделить всё
echo gmail('some_test_mail@gmail.com', 'password', 'support@microsoft.com');
Если кто напишет функцию работы с Gmail через POP SSL, буду безмерно благодарен [/code](empty) - Entire message
0 - Message header
1 - Body text
With an email message that is a multi-part message in MIME format, and contains the message text in plain text and HTML, and has a file.ext attachment, imap-fetchbody() will return something like the following for each requested part number:
(empty) - Entire message
0 - Message header
1 - MULTIPART/ALTERNATIVE
1.1 - TEXT/PLAIN
1.2 - TEXT/HTML
2 - file.ext
Now if you attach the above email to an email with the message text in plain text and HTML, imap_fetchbody() will use this type of part number system:
(empty) - Entire message
0 - Message header
1 - MULTIPART/ALTERNATIVE
1.1 - TEXT/PLAIN
1.2 - TEXT/HTML
2 - MESSAGE/RFC822 (entire attached message)
2.0 - Attached message header
2.1 - TEXT/PLAIN
2.2 - TEXT/HTML
2.3 - file.ext