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.
Related
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.
I've made a program to send mails, which have a numbers code in the subject. Now I need to write another one to be able to read through all the mail subjects searching for one specific one, and return the contents of the mail I was searching for.
To access your gmail inbox and manage emails you will have to use a module called "imaplib"
Here you have a short example to access your inbox:
import imaplib
mail = imaplib.IMAP4_SSL('imap.gmail.com')
mail.login('youremail#gmail.com', 'yourpassword')
mail.list()
# Out: list of "folders" aka labels in gmail.
mail.select("inbox") # connect to inbox.
I'm sure you can continue from here.
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.
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.
Basicly what I'm trying to do:
1- login to Yahoo Mail.
2- getting mails (with both content and sender) into a string.
I'm able to send emails (from Yahoo Mail) by using phpmailer class. But I haven't done anything for reading mails. Also I couldn't find any useful information. Hope you can help me.
Yeah, use the Yahoo! Mail API.
To get the last three messages use this query
select * from ymail.messages where numMid='3'
http://developer.yahoo.com/mail/