how to save gmail emails accordingly in database - php

i want to have a script that will save gmail emails from an account in mysql db using php. Mails(both freshly new and reply ones) will be marked to be in the same category if they have the same subject. That is just the same way in gmail or yahoo mail.
So far as I know gmail IMAP does not give the facility to track which are the reply mails.
Which API or whatever should I use??
The script will keep running.
Do I need to use scheduled task for that?

I haven't worked with that, but as i Google around, it turns out GMAIL provides IMAP Extensions API. And there you have an option to Access to the Gmail thread ID: X-GM-THRID

The reply emails as you call them are stored in the sent-mail folder, so just download them with IMAP.
You can track how emails go together using the In-Reply-To: and References: headers. Using the subject is not reliable.

#sof_user : every mail will have message_id in the header. google tracing the email with the id, if it is reply, then IN-REPLAY-TO will have the same id.

Related

Showing notification in web app when any mails received in Gmail

I want to show the notification in my web app whenever anyone will send the mail to my Gmail account.
I tried to do using IMAP, but IMAP is searching the mails based on the date. Like if I want to search mails from 11-10-2021 then it will give all the mails from 11th date to current date. But suppose I want the mails that comes after 11-10-2021 03:00 Pm, then it is not possible.
Any way to fetch the mails after particular time or based on the UID. Or is there any way to call the webhook whenever any mail receives in the Gmail account?
Note : I'm using the codeigniter framework.
Thanks in advance.
I think you need to do some settings in your Gmail
On the web
Open Gmail.
At the top right, click Settings. See all settings.
Scroll down to Desktop notifications and select New mail notifications on or Important mail notifications on (if you use Priority Inbox).
Click Save Changes.
let me know if this was useful
Okay then you need to turn on email notification in outlook
This video will explain everything.
https://youtu.be/Wvksb0VeQKk
Let me know if it helps

How to receive email GMAIL with LARAVEL?

I want to receive my mail (INBOX GMAIL) in my laravel application (5.x).
But I don't know how to do this.
I think I need to use a listener : when a mail arrives in my INBOX, I want a laravel event to read the email and save automatically the fields in my database (Subject, Message, Attachments...).
Then the mail in my INBOX will be in status "read".
Can you help me ?
Thank you :)
Interesting way to look at this but why not just have it send messages to the ticketing system and completely manage it there?
You would need to take a look at https://developers.google.com/gmail/api/v1/reference/
Basically you would just be managing emails in a different application. There are also rate limits to be aware of depending on the scope of this system.
It would be safer in that event to have gmail forward the emails to the ticketing system and 100% manage it there and use SMTP to just reply from the system.

Tracking emails opened in gMail

I want to track when emails are opened in gMail and display it somewhere.
I don't want to use third party mail service.
I need to track this with something else while using Gmail API.
A colleague said there is a tool like Shiftmail or something.
Do you know any tool to track email sent via Gmail API?
Do you know any tool to track email sent via Gmail API?
AFAIK, Official Gmail Blog have announced about an exciting change to how Gmail works wherein email providers track opens by inserting a small image–unique to each subscriber–into the email. When that image is loaded, we know the email has been opened.
Please check Open tracking in Gmail is now more accurate for more information regarding this change.
On the other hand, you may want to also check and see if Postmark - Tracking opens helps. Sending emails with open tracking enabled will embed an invisible pixel into your emails that allows Postmark to record information when the email is viewed. Please note, however, of the given limitations on the use of Postmark.
Is there an API to take advantage of Gmail's pixel caching?
I'm quite not sure if this is what you're looking for, but you may want to also check Tracking Pixel API. As mentioned,
Google Mail caches images which can cause your pixel to be cached and not fire on email open! To get around this, add a no-cache header to your emails and you should be good to go!

Extracting Content from Email

I want to develop an application that would extract the following things from an email id,
A notification about a new email
Subject
Sender
Total Unread emails
Now as I think it wont be easy to extract emails from all of the major email providers so I basically want to do it for Gmail.
I just need to find the way to do it. Please guide me. Thanks
It's actually fairly easy using the PHP IMAP extension. There are lots of functions there that you can use to list all emails in an inbox, get a count of them. Read their subjects or contents and such.
In GMail labels are the equivalent of folders in the IMAP docs.
You can connect to a GMail like this:
$mailbox = imap_open('{imap.gmail.com:993/imap/ssl}', 'email_address#gmail.com', $password);
Oh! Also you need to log in to GMail on the account you won't to allow email access to, go to Mail Settings -> Forwarding and POP/IMAP-> Enable IMAP
Documentation for the GMail API: https://developers.google.com/google-apps/gmail/
There will probably be some code monkeying involved in fetching the correct data, so I would recommend you to hire a nearby consultant doing it for you.

How can I get my mails from a pop-Server with php?

I am sending some mailings to a 5k list. I am not using any mailing commerce services. As expected I am getting some mails back from my mail-deamon and I would like to delete the those from the recipient-list. Is there a way to read the pop-mails programmatically?
is there maybe an easy and quick workaround?
A way to read POP mail via PHP: PHP: Download incoming email from POP3 or IMAP, parse it, and mark it as read/delete on server
(The code provided in the answer is using the functions suggested by Lèse majesté in its comment, but you find a ready to use small piece of working code thet does exacly what you need).
Obviously you will need to write also the code to programatically delete the address from your newsletter's DB.
I would use a cronjob (very easy to set on an hosting with cPanel) to programatically call the code that read the POP3 account and deletes the invalid addresses from DB.
A workaround? I don't know.
Can't you just set your "from" and "reply-to" address to an email address you can check? and then just check that email inbox to see what has bounced.

Categories