PHP code to Read Sent Items from an Email Account

戏子无情 提交于 2019-12-11 10:32:29

问题


I need to read sent items from an email account to insert the details into a database as part of development of a support ticket system.

I have managed to implement reading inbox emails using the below code and successfully inserted those into the database.

$stream = @imap_open($current_mailbox['mailbox'], $current_mailbox['username'], $current_mailbox['password']);
$overview = imap_fetch_overview($stream,$email_id,0);
$message = imap_fetchbody($stream,$email_id, 1.2);

I have searched all over the internet and stackoverflow to find a solution, but no use. I haven't found even a single discussion regarding this (Reading sent items from an email account).

Hope someone here can help me in this issue by sharing some useful code snippets or URLs for reference.

Thanks in advance.


回答1:


Got it working and successfully retrieved all sent emails by replacing {mail.domain.com:143/notls} with {mail.domain.com:143/notls}INBOX.Sent.

That is by setting the value of $current_mailbox['mailbox'] to {mail.remanns.com:143/notls}INBOX.Sent

The complete code is

$mailboxes = array(
    array(
        'label'     => 'domain.com',
        'enable'    => true,
        'mailbox'   => '{mail.domain.com:143/notls}INBOX.Sent',
        'username'  => 'mail@domain.com',
        'password'  => 'mypassword'
    )
);

$stream = @imap_open($current_mailbox['mailbox'], $current_mailbox['username'], $current_mailbox['password']);

Thank you Darren for guiding me through the right path. I figured it out by following you suggestion regarding finding the sent box name first.



来源:https://stackoverflow.com/questions/28870502/php-code-to-read-sent-items-from-an-email-account

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!