Parsing Current Gmail Email - php

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.

Related

Google Kix editor - how to send data using POST?

Can I include this text editor for Google Docs to my project?
https://github.com/benjamn/kix-standalone
or this is illegal?
I suspect that this person just steal the code. If this legal how can I send the data using POST to PHP? The HTML code does not have a textarea to send it, and I couldn't find a way to send the data.
I think it's illegal because this code is not provided by Google. One reason is that it is heavily based on server-side components see this
https://groups.google.com/forum/?fromgroups=#!topic/closure-library-discuss/SeZdenR-2vA
and the link you provided contains the obfuscated code and you will have no support if you use it.
hope this help

Get a list of mails with attachments on Gmail API

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/

Include whole page in php mail

Is it possible to include a separate html page in a php email?
Example, create a separate page that has all the content on it I want to email it and then include it in a php mail() on another page as the message?
Thanks
If you meant sending HTML email, yes. You can do that. You just need to add additional headers in the fourth parameter of mail() and pull the information from the HTML file you have using file_get_contents(). Please check this:
http://css-tricks.com/sending-nice-html-email-with-php/
Yes, it's possible exactly how rationalboss explained. Personally I use PEAR for html emails. It's a pain to get started with if you're not familiar to PEAR, but life has improved once I got it going.
Careful though, html/css does not have the same support in email clients that it does in browsers. You can create a beautiful page and find out that most people receive it with huge glitches due to certain CSS rules being ignored.
Best practice last I heard is to keep it simple and use inline styles for everything. Avoid floats and positioning. In fact, I believe it is actually still safer to use tables when dealing with email layouts if you need things to sit next to each other.
And then test in as many email clients as you can. Then cry and try to fix things.
I hear good things about Email on Acid for testing. It's a pay service but they offer a limited test for 3 clients as well.
If you're just doing a relatively simple email then it shouldn't be too bad. But if you're trying to make something that really looks great I recommend doing some googling on styling html specifically for emails.

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.

Is there a PHP script to mail forms for beginners for free?

I have a place where I want users to submit emails for newsletter subs and a place to submit an entire contact form. Zero php knowledge outside of know that it can do what I need.
There's a mail function built-in, take a look at
http://php.net/manual/en/function.mail.php
you will however, need to format the email body with the form data posted, of course.
Check out FormToEmail. From their site:
FormToEmail is a PHP form mail script.
It comes in a free version and a Pro
version. It processes web forms and
sends the contents of the form to you
by email. It will process any form. It
doesn't make forms but it comes with
HTML code for a basic contact form
that you can use on your website. It
is very secure and cannot be hijacked
by spammers. It is very simple to
install, you only need to add your
email address to it. Step-by-step
instructions written in plain English.
Actually, you don't need to do any php programming to create a such a setup. There are plenty of mailing list software apps available and you can grab a formmail script (like the one from Matt's Script Archive) and build the html with the right fields.
Use the mail function.
However be aware that you need to specify the correct headers yourself if you want to use html in your emails!
A common beginner's mistake is assuming you can simply use html tags with mail and it should work automatically.
Figured this was worth mentioning, since you are wanting to do a newsletter. If you try sending the email, and the raw html tags seem to appear in the message, this is your issue :)
As someone who is a PHP know-nothing, I often look for easy solutions to complex problems. Using a super simple PHP form can have some downsides such as getting massive amounts of spam if you don't have any measures to prevent that, setting up those measures is hard to do if you do not have any knowledge of PHP.
Here is what I found, there is a script here: http://www.dagondesign.com/articles/secure-php-form-mailer-script/
that you can download at no charge and the developer seems to have a lot guidance on how to install and use. I was able to set it up and get it to work.. not without having to spend quite of bit of time reading and trouble shooting. Hope that helps you.

Categories