Find my latest work and links to my YouTube, Twitter, etc. on my website: www.jeffgeerling.com.
If you like my work and want me to be able to keep improving it, please sponsor me on GitHub.
Simple wrapper class for PHP's IMAP-related email functions.
Home Page: https://packagist.org/packages/geerlingguy/imap
License: MIT License
Find my latest work and links to my YouTube, Twitter, etc. on my website: www.jeffgeerling.com.
If you like my work and want me to be able to keep improving it, please sponsor me on GitHub.
Woah, PHP short tags! (<?
). It's been a while since I've seen you...
Those need to go. Already spent about half an hour debugging problem on live site when I realized the silly short tags were causing problems with PHP > 5.3.x.
I've had this need more than once in different mail-handling applications: I want to strip out extra email messages below a reply message body. For example, consider an email like:
Here's my reply to your message!
On Sep. 20, 2012, Jeff Geerling wrote:
> This is the original message.
>
> -Jeff
I want to remove the message below the 'On Sep. 20' line, at least, so I'm adding a new method, cleanReplyEmail()
, which will implement a regex solution to remove any line beginning with a >
. This method is mentioned here: http://stackoverflow.com/a/12611562/100134
There doesn't seem to be an easier method, unfortunately.
To allow Imap to be used with other applications more easily, I think I'll start using namespaces in my PHP libraries. I'm going to use JJG as the vendor (as I do for other languages).
Fatal error: Class 'Imap' not found in /home/beezides/public_html/script_location on line 57
My code is here-
include("vp-includes/Imap.php");
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$user = $row['email'];
$pass = $row['pass'];
$host = $row['host'];
$port = 993;
$ssl = 'ssl';
$folder = 'INBOX';
}
}
$mailbox = new Imap($host, $user, $pass, $port, $ssl, $folder);
$mailbox->getMailboxInfo();
cool code. good work. not using ssl. any tips?
i upgraded to php 5.6
thank you
code is
include 'Imap.php';
$host = "localhost";
$user= "user";
$pass= "pass";
$port= "143";
$folder = "INBOX";
use \JJG\Imap as Imap;
$mailbox = new Imap($host, $user, $pass, $port, $folder);
$mailbox->getMailboxInfo();`
Fatal error: Class 'JJG\Exception' not found in Imap.php on line 64
also tried
$ssl = "false"; and $ssl = false;
$mailbox = new Imap($host, $user, $pass, $port, $ssl, $folder);
One of the most annoying things in the world is a system that pulls in the myriad of annoying and silly autoresponses from (almost always) Outlook. IMO, people should just forget about adding out of office replies, and others should simply presume that the person they emailed is either away or dead if they don't get a response within a few days.
Anyways, as it is, I have to deal with autoresponders, and they should, presumably, send back an 'Auto-Submitted' header in the email (see this answer on Stack Exchange). However, I've never gone deep into this area, so I need to do some research and see how the out of office replies work from different clients.
Here are some interesting tidbits I found when looking up various solutions to the autoresponder/vacation/away/out-of-office problem:
X-Auto-Response-Suppress
header to indicate to mail servers whether the email should be responded to. See (X-Auto-Response-Suppress documentation)[http://msdn.microsoft.com/en-us/library/ee219609(v=exchg.80).aspx]. (Exchange, btw, also only sends one out-of-office reply per email sender... so that's a nice non-proliferation tool, at least).Attachment support would make this a pretty killer class.
Right now, some messages that PHP IMAP passes through with 7BIT
encoding still have characters like =A0
and =
all over the place. Other messages are actually base64-encoded, and need decoding.
I'm adding some simple/manual rules and loops in the currently-empty decode7Bit()
method to detect any bits of encoding and decode them properly.
Now that I'm using this class in an application, I'm finding that there are a few more quirks that need ironing out. For one, I need to list all mailboxes in the account, so I've added a getMailboxInfo()
method to list all mailboxes by name.
I've also renamed the mailbox methods to getMailboxInfo()
and getCurrentMailboxInfo()
.
I've also conformed to a more CRUD-style naming convention for messages: you can getMessage()
and 'deleteMessage()` now.
I've also fixed the README file with updated method names.
I'm getting errors like:
Notice: Unknown: Sequence out of range (errflg=2) in main() (line of ).
This happens whenever I check for new messages and there are none. Which is quite annoying, in my logs :)
It looks like there's an open issue to add a note about this warning, but it's not documented yet in the PHP docs. Took me a while to track down the cause of the issue.
Currently, we cut off reply text in the cleanMessage()
method for Mac OS X Mail, iOS Mail, and Gmail, but it looks like Microsoft Office puts in a line like:
In a message dated 10/1/2012 2:00:24 P.M. Central Daylight Time,
[email protected] writes:
Would be nice to remove that and anything beyond...
(Note: This might actually be AOL...).
Many emails from Yahoo web mail seem to have the following block of text above replies, which should be cut out (along with anything below, probably), as the emails also don't include >
for quoted text...
From: [Sender]
To: [Person]
Sent: Tue, October 2, 2012 7:14:08 AM
Subject: [Subject here]
It's annoying to have to detect Base64-encoded text in all the messages. Therefore, our getMessage()
method should do this automatically, if the body is Base64...
I've been working on a bunch of little tweaks and fixes over the past few days while using the class on a live site. I'll post these in a commit to this issue.
One of the main missing features I just noticed is the ability to move messages into different boxes. Right now, you can read and delete messages, but you can't move them into another box (for archival, sorting, etc.).
This will hopefully be pretty simple.
How come you don't call imap_errors() on your thrown exception instead of imap_last_error()?
I had an issue with notices being thrown because that doesn't clear the error stack like imap_errors() does. I hope i didn't miss something, what do you think?
Since I've changed probably 80% of the original forked repo, I might as well go the full length and apply Drupal coding standards to everything, including whitespace.
I'm going to switch from four to two spaces. Note that this is not in full compliance with PSR-1, but it's mostly there.
My favorite projects seem to have nifty logos. So I'd like to create a nice, simple logo for Imap.
I'm thinking of using this graphic in the logo: http://openclipart.org/detail/166281/mail-badge--by-
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.