Thursday, 26 July 2012

Simple Mail Transfer Protocol

Simple Mail Transfer Protocol is an Internet standard for email transmission across Internet Protocol networks.
SMTP was first defined by RFC 821 (1982), It use TCP port 25.
SMTP was updated by RFC 5341(2008), It use TCP587. It is known as ESMTP and is the protocol in widespread use today.

Mail server and other transfer agent use SMTP to send & receive email. whereas User level client mail application use SMTP to send an email and for receiving email they use Post Office Protocol (POP) or the Internet Message Access Protocol (IMAP) or aLotus Notes/Domino to access their mail box accounts on a mail server.



Mail processing model






Email is submitted by a mail client (MUA, mail user agent) to a mail server (MSA, mail submission agent) using SMTP on TCP port 587.
 MSA delivers the mail to its mail transfer agent (MTA, mail transfer agent).


Mail Read Feature Overview
FeatureMboxMaildirPop3IMAP
Storage typelocallocalremoteremote
Fetch messageYesYesYesYes
Fetch MIME-partemulatedemulatedemulatedemulated
FoldersYesYesNoYes
Create message/folderNotodoNotodo
FlagsNoYesNoYes
QuotaNoYesNoNo


Thursday, 19 July 2012

Regular Expression

Regular Expression


Following are some Basic terms of Regular Expression which we should be aware.

1. literal: It is Character(s) OR words which we want to search in regular expression.
For Example:
                we want to search "tutorial" in the "php-tutorial-php.blogspot.in".
                Here "tutorial" is literal.


2. Meta Character: It is special chacter(s) which have special meaning in Regular Expression.
For Example:
                *, ., /, \, ? and ^.


3. Target string: The string in which we want to search the string.
For Example:
                we want to search "tutorial" in the "php-tutorial-php.blogspot.in".
                Here "php-tutorial-php.blogspot.in" is target string.


4. Regular expression: The regex with which we find the string.
For Example:
                we want to search "tutorial" in the "php-tutorial-php.blogspot.in" with regex    /(tutorial)/
                Here "/(tutorial)/" is Regular Expression.





Following are the Regular Expression with matches tested for PHP only.


An Introduction of Regular Expression


In computing, a regular expression provides a concise and flexible means to "match" (specify and recognize) strings of text, such as particular characters, words, or patterns of characters. Common abbreviations for "regular expression" include regexp and regex.
The concept of regular expressions was first popularized by utilities provided by Unix distributions, in particular the editor ed and the filter grep.
Regular Expression  Matche
^A
"A" at the beginning of a line
A$
"A"  at the end of a line
A\^
"A^" anywhere on a line (slash for escape spec. mean of ^) 
\$A
"$A" anywhere on a line
^\^
"^" at the beginning of a line
\$$
"$" at the end of a line
[0]
The character "0"
[0-9]
Any number
[^0-9]
Any character other than a number
[-0-9]
Any number or  "-"
[0-9-]
Any number or  "-"
[^-0-9]
Any character except a number or  "-"
[0-9]\]
Any number followed by a "]"
[0-9-z]
Any number, or any character between 0-9  and "z"
[0-9\-a\]\]
Any number, or - or a
\*
Any line with an asterisk
\\
Any line with a backslash
^\*
Any line starting with an asterisk
^A\*
Any line starting with an "A*"
^AA\*
Any line if it starts with one "AA*"
^A(A)*B
Any line with one or more "A"'s followed by a "B"
e.g.
AB, AAB, AAAB, AAAB
^A{4,8}B
Any line starting with "A" having 4-8 char and followed by B
eg
AAAAB, AAAAAAB, AAAAAAB
^A{4,}B
Any line starting with "A" min 4 character and followed by B
^A{4}B
Any line starting with "AAAAB"
A{4,8}
Any line with "A{4,8}"