簡體   English   中英

如何使用php接收電子郵件附件?

[英]How to receive email attachments using php?

我正在嘗試檢索cpanel電子郵件中的電子郵件和附件。 電子郵件已正確檢索,但是我無法檢索附件。 我究竟做錯了什么?

我的源代碼:

$emailAddress = "email@email.com" ; // Full email address
$emailPassword = "password";        // Email password
$domainURL = 'email.com';              // Your websites domain
$useHTTPS = true;

$inbox = imap_open('{'.$domainURL.':143/notls}INBOX',$emailAddress,$emailPassword) or die('Cannot connect to domain:' . imap_last_error());
   /* grab emails */
  $emails = imap_search($inbox,'UNSEEN');
  if($emails) {        


    /* 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);
        $message = imap_fetchbody($inbox,$email_number,2);

        $header = imap_headerinfo($inbox, $email_number, 1);
        /* output the email header information */

        $subject_other= $overview[0]->subject;
        $sender_name_other= $overview[0]->from;
        $date_other=$overview[0]->date;
        $msg_to_other=$overview[0]->to;
        $msg_from_other = $header->from[0]->mailbox . "@" . $header->from[0]->host;
        $msg_msg_other = $message;

        //store to database email data

        mysqli_query($con,"insert into other(msg_to, msg_from, sender_name, subject, message, msg_date_time) values('$msg_to_other', '$msg_from_other', '$sender_name_other', '$subject_other', '$msg_msg_other', '$date_other')");             
     }


  } 

/* close the connection */
imap_close($inbox);
 // insert into other email in database
foreach($emails as $email_number) {
  $structure = imap_fetchstructure($inbox,$email_number);
}

http://php.net/manual/zh/function.imap-fetchstructure.php

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM