Access gmail or yahoo mail using script - php

I was wondering how one would go about writing a php script to access mail from yahoo or gmail ?

The "simplest" way would be to use IMAP to access the mails (i.e. don't try any kind of HTML scraping !). I have no idea for Yahoo, but I know you can enable IMAP in gmail.
There are several libraries in PHP that allow one to use the IMAP protocol to access a mailbox ; for instance :
There are functions provided in PHP (You might have to install the extension, though) : IMAP, POP3 and NNTP
Or you could use something like Zend_Mail.

You could use the Zend Framework Zend_Mail functionality, this would allow you to connect to GMail/Yahoo/etc with POP3 or IMAP.

One more to add to Pascal's suggestions: libgmailer

Related

How to access mail from gmail

I was using imap functions in my app to access gmail. Unforunately I have not been able to use imap any more. I am using php. Is there any alternative way like (api..) to access gmail.
I appreciate any help.
In short, no. The only GMail API which provides access to mail is the IMAP one.
You don't explain why you can't use imap any more, but that's ok.
You can use php imap extension to connect with pop3!
Here is an example.
Try Zend Framework:
Code is Here
http://framework.zend.com/manual/en/zend.mail.read.html

Using curl to send mail from gmail

Is it possible to login to my gmail account and send mail using curl in php? I don't want to use pop3 or any other function.
$msg = "something";
$email = "sa#sas.com";
$pass= "something"
function send($msg, $email, $pass)
{
//something
}
I have never used curl, to be honest. Have just heard of it.
It is theoretically possible, but extremely complex and subject to breaking whenever Google decide to change their HTML interface. Not a good idea.
Your best option is to use Google Mails's SMTP servers. Mailer packages like SwiftMailer make this easy to set up.
Here is an example for how to connect to GMail with SMTP.
You may do it with libcurl without many troubles. Here is an example http://curl.haxx.se/libcurl/c/smtp-tls.html of how to send email using TLS (all you need to send via gmail) in C. I believe libcurl PHP port provides the same ability.
I believe it is possible but the codebase would be huge and the benefits very small compared with using imap or pop3 or other services.
Why do you want to do this?
p.s. gmail has a limit on the numbers of email you cand send per hour, as far as i know. So, if you're trying to use gmail to send mass emails i would advise against it.
I should use SMTP for it, there are some great mailer classes for SMTP (E.g. Zend_Mail). Zend components can be use stand alone and are very great.
Libcurl is designed to support smtp email since version 7.20 (April 2010). It also support several authentication methods (SSL, TLS, CRAM-MD5)

sending IMAP commands using php

I'm trying to access yahoo mail IMAP server with a php script. I read that yahoo requires a specific IMAP command “ID ("GUID" "1")”. How do I send this command ?
As of this writing, I don't believe you can access Yahoo's IMAP services externally. However, in general, you will want to use socket functions.
http://us.php.net/manual/en/ref.sockets.php
This library was released a couple of days ago and says it supports Yahoo!'s IMAP variant: http://github.com/petewarden/handmadeimap (I've not tried it myself)

google apps is setup on my server, how do i get php mail() to use it?

I've got google apps setup on my server with all the correct MX records etc, now i want to start testing it.
I want to use it for all automated
emails (registration, lost password
etc).
I'm testing on a localhost.
You'll probably want to use PEAR Mail, and set it up using the SMTP settings provided to you by Google. I don't believe the built-in mail() command supports TLS, which is required for sending using Google.
Ok, the solution i've found is to use the PHPMailer class found here:
http://phpmailer.worxware.com/

How to export all Yahoo emails using PHP

Can anyone tell me what the best way to export about 90K emails off of a Yahoo account? The way it stands now, I believe that every email would need to be extracted one by one. I'd like to write a program to do this for me. Can someone give me any ideas as to the best way to so this?
What I am after are the sender email addresses (that are not already in my "contacts") so that I can use them in a list manager.
I would suggest using POP3 access to retrieve your mail. IMAP will be ideal, but not sure if all Yahoo accounts have IMAP access.
You probably do not need to do it programmatically if you just want to archive them.
E.g.: How do I archive messages?
I've done similar tasks with gmail using their IMAP interface and PHP's IMAP package.
Here is the docs: http://php.net/manual/en/book.imap.php
I believe Yahoo Mail also supports IMAP...
I believe Yahoo mail supports IMAP, which would be by far the best way to access the sender name for all your emails. It also looks like PHP has an imap module which will make this easier.
All you have to do is plug the pieces together. :)

Categories