codice di lavoro completa con un esempio in linea
Extract email addresses list from inbox using PHP and IMAP casella di posta-utilizzando-php-e-imap
penso che tutto ciò che serve è solo per copiare lo script .
sto pubblicando due funzioni fondamentali del codice anche qui (grazie a commento di Eineki)
function getAddressText(&$emailList, &$nameList, $addressObject) {
$emailList = '';
$nameList = '';
foreach ($addressObject as $object) {
$emailList .= ';';
if (isset($object->personal)) {
$emailList .= $object->personal;
}
$nameList .= ';';
if (isset($object->mailbox) && isset($object->host)) {
$nameList .= $object->mailbox . "@" . $object->host;
}
}
$emailList = ltrim($emailList, ';');
$nameList = ltrim($nameList, ';');
}
function processMessage($mbox, $messageNumber) {
echo $messageNumber;
// get imap_fetch header and put single lines into array
$header = imap_rfc822_parse_headers(imap_fetchheader($mbox, $messageNumber));
$fromEmailList = '';
$fromNameList = '';
if (isset($header->from)) {
getAddressText($fromEmailList, $fromNameList, $header->from);
}
$toEmailList = '';
$toNameList = '';
if (isset($header->to)) {
getAddressText($toEmailList, $toNameList, $header->to);
}
$body = imap_fetchbody($mbox, $messageNumber, 1);
$bodyEmailList = implode(';', extractEmail($body));
print_r(
',' . $fromEmailList . ',' . $fromNameList
. ',' . $toEmailList . ',' . $toNameList
. ',' . $bodyEmailList . "\n"
);
}
fonte
2018-01-16 00:58:37
Questo è il mio colpo di testa: MIME-Version: 1.0 Ricevuto: da 10.227.37.212; Mer 21 Lug 2010 12:21:40 -0700 (PDT) Data: Mercoledì, 21 Luglio 2010 12:21:40 -0700 Message-ID: Oggetto: Personalizza Gmail con colori e temi Da: team di Gmail A: Frederik Heyninck Content-Type: multipart/alternative; boundary = 0016e6d5fc53164fb6048beab667 Quindi nessun indirizzo email. Quello è il problema. –