PHP code example of superkingm / mail

1. Go to this page and download the library: Download superkingm/mail library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

superkingm / mail example snippets


        $username = '[email protected]';
        $password = 'xxxxx';//邮箱登录密码
        $email_address = '[email protected]';
        $mail_server = 'pop.163.com';
        $server_type = 'pop3';
        $port = 995;
        $ssl = true;

        $username = '[email protected]';
         $password = 'dsaffsdfsdfsdfd';//授权码
         $email_address = '[email protected]';
         $mail_server = 'imap.qq.com';
         $server_type = 'imap';
         $port = 143;
         $ssl = false;

        //pop3或imap配置信息

        $mail = new MailBox($username, $password, $email_address, $mail_server, $server_type, $port, $ssl);
        $mail->connect();
        $mail->getMailTotal();//获取邮件总数,mid 从1到总数
        $head = $mail->getImapHeader($mid);//获取原始的邮件头部信息
        $mail->getHeaders($mid);//获取头部信息例如 发件人,主题,收件人等
        $mail->getBody($mid);//获取邮件内容
        $mail->markMailRead($mid);//将邮件标记为已读
        $mail->markMailUnRead($mid);//将邮件标记为未读
        $mail->isUnread($head);//判断邮件是否被读取
        $mail->deleteMail($mid);//删除邮件
        $mail->getDate($mid);//获取邮件时间