Jump to content

Get Message From GMail And Write It To Mysql Table


fgtsai0418

Recommended Posts

Now I can do is it connect to Gmail but I don't know how to fetch a message only for "@123mobile.com" this domain name.
*****************************
<?php
$authhost="{pop.gmail.com:995/pop3/ssl/novalidate-cert}";
$user="username@gmail.com";
$user="name@gmail.com";
$pass="pwd";
if ($mbox=imap_open( $authhost, $user, $pass ))
{
echo "<h1>Connected</h1>n";
$check = imap_mailboxmsginfo($mbox);
echo "Date: " . $check->Date . "<br />n" ;
echo "Driver: " . $check->Driver . "<br />n" ;
echo "Unread: " . $check->Unread . "<br />n" ;
echo "Size: " . $check->Size . "<br />n" ;
imap_close($mbox);
} else
{
echo "<h1>FAIL!</h1>n";
}
?>
Link to comment
Share on other sites

I use imap_check instead of imap_mailboxmsginfo to get information about the mailbox, including the number of messages, and then loop through and use functions like imap_headerinfo and imap_body to get information about each individual message. You can get the from header and check it for whatever you want.

 

http://www.php.net/manual/en/function.imap-headerinfo.php

Link to comment
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...