Get a list of mails with attachments on Gmail API - php

So I have to build a browser extension that extracts all the emails with extensions. I am at a loss however, how to go about it. What I essentially need is for the extension to extract a list of emails with descriptions as to whether they have attachments with them.
Now I tried the gmail atom feed
but it only shows unread emails, and doesn't give a lot of information about the message either. Is there another method of doing it.
Is there like an API for gmail that allows all this to be done easily and seemlessly. I feel like I am missing something obvious. I know i am being vague here, but I really don't have clue how to do this.

It can be done using IMAP doing search for "has:attachment". Samples and description can be found under the following resource:
developers.google.com - Google Apps Platform - Google Developers

I know this is quite an old question but since this question was posted Google has released a
WEB API to work with gmail.
https://developers.google.com/gmail/api/

Related

Filter latest reply from php imap

I'm using the PHP imap lib. I have no problems pulling e-mails and reading the plain body. ($mail->textPlain). However this takes the entire body (including the conversation/history). I want to filter the history and only keep the reply. I tried using regex and that works fine for Gmail but for other email clients it doens't work. Does someone knows a workaround or a library?
preg_replace('#(^\w.+:\n)?(^>.*(\n|$))+#mi', "", $mail->textPlain);
I'm aware that php imap does not provide a method for that but I'm want to know if there are libraries for it.

Does whatsapp ABID (Address book ID) work in php?

I am using wordpress site and sending user to open a particular chat on whatsapp. Its working fine in case of simple text send like this:
Chat
But i want to let the users to open a particular contact. I have seen this functionality in iOS but dont know weather its also applicable in php or not. Here is the code i am trying:
Chat
There are the links that i found for help:
https://www.macstories.net/tutorials/use-whatsapps-url-scheme-with-drafts-launch-center-pro-or-a-bookmarklet/
http://www.technetexperts.com/mobile/interact-with-whatsapp-from-ios-application/
What you are mentioning is NOT dealing with PHP, since PHP is a server-side language and you are only dealing with HTML (client-side).
Nevertheless, that being said, you should better use the official solution that replaces ABID need. I've mentioned it and another schema solution that also seems to be working (july 2017) in THIS OTHER ANSWER (because S.O. policies I had to put a link to the solution, no duplicates).

Parsing Current Gmail Email

Hey guys, basically what Im having problems currently is finding a way to parse a current email that someone is reading through gmail once they click a button that will be provided through an extension on the side of the email. I want to just extract the subject and the contact name of the email I'm reading on screen and store into some variables in php.
Possible solutions I had in mind was to use the imap functions that come with php to figure out what email I was reading currently, but Im not sure how to go about doing this. Another solution that came to mind was HTML scraping, but not sure how complicated it could be by doing this. Maybe there is an easier way, and hopefully someone can help me out?
Edit
I think Im going to do a different solution to this problem will post when I figured it out.
I decided to use Gmail Contextual Gadgets which can extract information from the email and be used to make any application.

Edit an email subject line (IMAP)

I am trying to integrate IMAP email processing with another in house system that bases what it uses off of the subject line / email content.
We need to be able to change the text of the subject line before moving the email to a new folder. What/where would be a good place to start?
I've had a look around and it IS possible in a manual sense, via a thunderbird plugin or using outlook. I just can't seem to find a relevant example in PHP, or any other language for that matter. I also hear the idea is flakey at best as you need to modify the email content and upload it back to the imap server.
The outlook implementation seems to delete the original and save a new one to your IMAP folder on the server.
Side note: Yes I know it is a weird requirement, and although forwarding the email to ourselves then moving it is our fall back plan it is not much liked as it moves original headers useful for things like reply-all.
Any suggestions appreciated.
PS If I'm blind and there is something obvious I'm missing in the manual let me know.
Do you already have any code built to handle the email processing? IMAP subject line information is stored as a header so you would need to utilize the PHP functions of imap_headerinfo() and/or imap_fetchheader() depending on the functionality you're looking for to achieve this. You could have PHP check each message header and if it matches X format, remove the message, and create a new one with the appropriately modified header information.

Manipulating the content of an email message

I am looking for a solution that will enable me to connect to a mailbox, obtain an email, apply specific modifications to the email body (for example, change the content), and then forward the newly modified email to a new email address.
The trick is that such modification must not destroy the format and headers of the original email and I must not lose any attachments that were in the original email.
The sort of manipulation that will be performed will need to be done by an external process that knows the logic of my application.
The solution I am looking for can be an external software that can invoke some API for processing the content of the emails, or even API by itself that my code will invoke.
Our solution is currently based on PHP, but any other solution is also acceptable.
I started working with the Zend Mail library but I am running into problem having to understand the inner-workings of email formats. I wouldn't want to start messing around with the mime objects in the email format. I only want to alter the textual content of the message and keep the rest untouched.
http://php.net/manual/en/book.imap.php - functions that let you manipulate email systems.
What mail server are you using? In qmail its easy to process any incomming email. You can put any script in any language to process the lines of the email.
If you have IMAP access to your server you can use the php IMAP lib. http://www.php.net/manual/en/book.imap.php
I wrote a library as part of a larger open source app that may help you a bit. Its an object orientated wrapper around the PHP imap functions and can be found at google code.
Unfortunately this doesn't do exactly what you want. What in the message are you trying to change? I may be possible to just grab a raw version and specifically search out what you want to change, ignoring the whole mimetype processing altogether, and then just send the whole message along again.
Resending the email is simple enough, and this (small tutorial)* on sending email with attachments can refresh you on the basics (although most of what is in there you can skip as the attachments and mimetypes will already be built).
* I can't post the link because my reputation isn't high enough for two links in a single post, so I'll add it in a comment.

Categories