benhall14 / php-imap-reader Goto Github PK
View Code? Open in Web Editor NEWA PHP class that makes working with IMAP in PHP as easy as possible.
Home Page: https://conobe.co.uk/projects/php-imap-reader
License: MIT License
A PHP class that makes working with IMAP in PHP as easy as possible.
Home Page: https://conobe.co.uk/projects/php-imap-reader
License: MIT License
Help and example example for using single email mode with id.
$imap = new Reader(IMAP_MAILBOX, IMAP_USERNAME, IMAP_PASSWORD, ATTACHMENT_PATH);
$imap
->id($_GET['em'])
->get();
foreach ($imap->emails() as $email) {
echo 'SUBJECT: '.$email->subject().'<br/>';
echo 'SENDER: '.$email->fromEmail();
echo ' --- '.$email->date('Y-m-d H:i');
echo '<hr/>'.$email->plain();
echo '<hr/>';
}
not show!
When using $email->html()
i get a warning:
( ! ) Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array\|string is deprecated in /vendor/benhall14/php-imap-reader/src/phpImapReader/Email.php on line 836
php-imap-reader/src/phpImapReader/Reader.php
Line 962 in ba7bca0
This should not also mark as read
$email->setRawBody(imap_fetchbody($this->stream(), $uid, '', FT_UID | FT_PEEK));
So has to follow flags
$email->setRawBody(imap_fetchbody($this->stream(), $uid, '', $options));
I added this and works perfect for me using your library. THANKS A LOT!!
/**
* Move mail to specific folder
* @param string $folder Destination folder
* @param int $email_id The id of the email to move.
* @return boolean The result of the action.
*/
public function moveEmailToFolder($folder,$email_id){
return imap_mail_move($this->stream(), $email_id, $folder);
}
Hi, thanks for a great little imap parser, I'm using it in my LibreCMS project in my webmail part of the CMS. However, I've discovered some emails that are received have the body encoded with a base64 encoding.
I've had a look through your source, and it looks as though you have an imap_base64 in the receiving part of the script. Should it be decrypting base64 or base8 decryped emails? I tried to check if you have a check to do so, but couldn't find it. I could easily store a flag in my database to indicate the type of encoding, but I need to be able to tell which meissages are encoded, and which aren't.
Again, thanks for making the script, it's easy to use, and works great for my purposes.
How delete email ?
$email->delete() ?
Please add this to Reader.php:
public function expunge()
{
return imap_expunge($this->stream());
}
without it there is no way that messages that are marked for delete are really deleted.
Hi, I use your class from few days and I saw a little problem.
I have mail with 4 .html attachments and two images inside message.
And When I list attachments throught your class is showing me only 3 attachements but inside are two gifs (images from message) and one html file.
When I use method html message is empty but when i get plain is getting message but without that images.
I got another mail but with 4 .xls files and 2 images inside message and its the same problem in attachments are only two images and one xls file.
And second it is possible to detect encoding of attachments? Because I saw that in mails for each attachment it could be different encoding and from time to time when class save attachments theirs names are wrong.
I hadn't noticed this before until just now. The error is thrown if limit()
has no value assigned to it. Or it isn't used at all with get()
.
[06-May-2019 23:55:41 Australia/Hobart] PHP Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/LibreCMS/core/imapreader/Reader.php on line 678`
I love this class and I have a particular use case that involves me saving a copy of the email in eml format (headers and body) to the local disk. Is this possible? I cant see a way looking through the code.
Hi,
I'm using phpImapReader to pull in attached files from an email account. I wasn't able to get the EmailAttachment->contents to work.
It looks like the issue is in line 1237 of the Reader.php file.
$attachment->setAttachmentContent($data)
is commented out.
I replaced it with:
$attachement->setAttachmentData($data)
That seems to work.
Regards,
Greg
Hi. How i get all messages in IMAP folder number?
Running composer with stable settings to clone version 1.0 will retrieve files with the old folder naming. I recommend you release a new version that includes commit 476c21c to include the new folder naming.
How get newMessages ?
Hi, i'm trying to retrieve content data of an attachment with: $attachment->content(); but i get this error:
Warning: Undefined property: benhall14\phpImapReader\EmailAttachment::$attachment_data ...... on line 173
if I print a var_dump i get my attachment like this:
object(benhall14\phpImapReader\EmailAttachment)[24]
public 'id' => int 738572691
public 'name' => string 'logo.png'
public 'file_path' => null
public 'type' => string 'attachment' (length=10)
public 'mime' => null
I've set:
define('ATTACHMENT_PATH', false);
If I set:
define('ATTACHMENT_PATH', __DIR__ . '/attachments');
I get ALL attachments to be downloaded (of all emails). My goal is to download attachments only for a specific email, searching inside the header (like my past ticket closed)... but to do my search I need to download ALL emails, then filter trought header...
Any suggest? thanks
This occurs when the email object has no entries:
Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/vhosts/developerbootcamp.co.uk/admin.developerbootcamp.co.uk/libs/php/phpImapReader/Reader.php on line 802
I've tried connecting to the mailbox using this:
$imap = new Reader(IMAP_MAILBOX, IMAP_USERNAME, IMAP_PASSWORD, false, false);
And the emails retrieve correctly, but they're always flagged as read.
I've even tried commenting out this section
if ($this->mark_as_read) {
//$this->markAsRead($id);
}
And still they're flagged as read.
This is how I'm retrieving the emails:
$imap->unseen();
$imap->get();
Fatal error: Uncaught ErrorException: Creation of dynamic property benhall14\phpImapReader\Reader::$encoding is deprecated in /var/www/html/vendor/benhall14/php-imap-reader/src/phpImapReader/Reader.php on line 145
Tried to create Reader instance like this:
use benhall14\phpImapReader\Reader;
$imap = new Reader(
$_ENV['IMAP_SERVER'],
$_ENV['IMAP_LOGIN'],
$_ENV['IMAP_PASSWORD'],
mark_as_read: false
);
And as I see, there really is no $encoding field in the Reader class. Fix it please.
Hi, is there any function to filters email by custom header? For example "References" key or any other custom ones? thanks
Hi,
it would be great, if this class would also support creating new mailboxes/folders via imap_createmailbox
. Maybe including the possibility to determine, if the given mailbox/folder already exists.
hi Benjamin,
i can`t find imap_list.
Hello,
When trying get emails error showing.
count(): Parameter must be an array or an object that implements Countable
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.