Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Reading E-Mail using imap in PHP

variable type

  • Please log in to reply
9 replies to this topic

#1 Affix

Affix

    CC Regular

  • Just Joined
  • PipPipPip
  • 46 posts

Posted 16 February 2009 - 11:36 PM

IMAP functions of PHP allow Communication with IMAP and POP3 Services trhough the PHP Enabled Webserver.

To use imap you must start your imap session using the imap_open() it is best to do this in a Variable so you dont leav an pen session.

$mailbox = imap_open ("{localhost:110/pop3}INBOX", "user", "pass");

we now have a Stream to a pop3 server running on localhost(The host of the script).

What if we want to read the stream.

Reading an IMAP stream is fairly simple as long as you know the basic pre-defined variables for doing so.

Why dont we check for some new email?

Ok then define a variable i will call $checker you name it what you want. Add the following code to your variable

$checker = imap_check($mailbox);

Notice our mailbox has cropped up again the imap_check function will check using other variables linked to this.

For example
Total Number of Messages : <?= $checker->Nmsgs ?>
Name of Mailbox : <?= $checker->mailbox ?>
Note that this is 100% Correct Syntax

Those are 2 basic examples of how to check the mailserver Here are a list of all the different Variable Types for imap_check()

Date :: Get the Date of last received message
Driver :: Show the Connection Type
Mailbox :: Display Mailbox Name
Nmsgs :: Total Messages
Recent :: Number of recent messages

Well this is the Basic IMAP check Function of PHP I will soon post a tutorial for IMAP headers also.

Thanks for reading,
Affix
  • 3

#2 Guest_Jordan_*

Guest_Jordan_*
  • Guest

Posted 17 February 2009 - 01:42 PM

Very nice tutorial. +rep
  • 0

#3 Affix

Affix

    CC Regular

  • Just Joined
  • PipPipPip
  • 46 posts

Posted 17 February 2009 - 11:39 PM

Thanks for your comments :)

I will write some more
  • 0

#4 ReekenX

ReekenX

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 123 posts

Posted 18 February 2009 - 12:29 AM

+rep ;)
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#5 Affix

Affix

    CC Regular

  • Just Joined
  • PipPipPip
  • 46 posts

Posted 18 February 2009 - 12:39 AM

you can use this with a catchall address and create your own E-Mail Provider :)

Just thaught I would throw that in there :)

Thats why I learned to do it lol gave up on the project though was taking up too much time
  • 0

#6 Brandon W

Brandon W

    CC Mentor

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2092 posts
  • Location:Ipswich, Australia
  • Programming Language:C, Java
  • Learning:Java, C++, JavaScript

Posted 20 February 2009 - 03:02 AM

Hmmm interesting. I never knew PHP had an area for this, really amazing. +rep
  • 0
I've returned...

#7 tecktalk

tecktalk

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 155 posts

Posted 25 March 2009 - 06:31 AM

Yes.. I was finding this one.. was a bit confused how to do.. Thanks for sharing with us.. +rep from me too :)
_______________________
gadgets
women for tedisco
  • 0

#8 phpforfun

phpforfun

    Speaks fluent binary

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1056 posts

Posted 31 March 2009 - 06:52 AM

dude thats awesome!
  • 0

#9 mortezaipo

mortezaipo

    CC Lurker

  • New Member
  • Pip
  • 6 posts
  • Programming Language:C, C++, PHP, JavaScript, Assembly, Bash
  • Learning:C, C++, PHP, JavaScript, Assembly, Bash

Posted 27 January 2013 - 06:00 AM

how to read "draft" or "sent" folder mails?
  • 0

#10 ali156354

ali156354

    CC Lurker

  • New Member
  • Pip
  • 5 posts

Posted 27 September 2014 - 08:24 AM

thanks alot


  • 0





Also tagged with one or more of these keywords: variable type