2013-04-17 4 views
1

Мне нужно было получить адрес электронной почты, с которого я получаю/получаю письма в папке «Входящие»! что я должен сделать для этого, я в это время имеют следующий кодPhp доступ к почтовому ящику электронной почты для адреса электронной почты

<?php 
    $mbox = imap_open("{imap.gmail.com:993/imap/ssl}INBOX", "[email protected]", "passw0rd") 
     or die("can't connect: " . imap_last_error()); 

    $status = imap_status($mbox, "{imap.gmail.com:993/imap/ssl}INBOX", SA_MESSAGES); 
    if ($status) { 
     echo $status->messages; 
    } 
?> 

ответ

8
<?php 
/* connect to gmail */ 
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX'; 
$username = '[email protected]'; 
$password = 'davidwalsh'; 

/* try to connect */ 
$inbox = imap_open($hostname,$username ,$password) or die('Cannot connect to Gmail: ' . imap_last_error()); 

/* grab emails */ 
$emails = imap_search($inbox,'ALL'); 

/* if emails are returned, cycle through each... */ 
if($emails) { 

    /* begin output var */ 
    $output = ''; 

    /* put the newest emails on top */ 
    rsort($emails); 

    /* for every email... */ 
    foreach($emails as $email_number) { 

     /* get information specific to this email */ 
     $overview = imap_fetch_overview($inbox,$email_number,0); 


     $output.= 'Name: '.$overview[0]->from.'</br>'; 
      $output.= 'Email: '.$overview[0]->message_id.'</br>'; 



    } 

    echo $output; 
} 

/* close the connection */ 
imap_close($inbox); 
?> 

ссылка: Update code from

EDIT

subject - the messages subject 
from - who sent it 
to - recipient 
date - when was it sent 
message_id - Message-ID 
references - is a reference to this message id 
in_reply_to - is a reply to this message id 
size - size in bytes 
uid - UID the message has in the mailbox 
msgno - message sequence number in the mailbox 
recent - this message is flagged as recent 
flagged - this message is flagged 
answered - this message is flagged as answered 
deleted - this message is flagged for deletion 
seen - this message is flagged as already read 
draft - this message is flagged as being a draft 
+0

я редактировал свой код .Вы получите имя и адрес электронной почты. –

+0

Требуется адрес электронной почты! Из чего он вернулся? if im correct – Naaz

+0

Я обновил anser со всеми данными, которые вы можете получить, используя этот результат с описаниями. –

Смежные вопросы