email-to-blog how it works. this is the «email-to-blog» system architecture
TRANSCRIPT
Email-to-Blog
How It Works
Database AccessObjects
PostgreSQLdatabase
Mailbox
MailboxW atcher
P O P 3
BlogBean
MessageBean
AuthorBean
JSP-basedW eb-App
JD B C
B log U ser
H TTP
B log A dm in
H TTP
S M TP
Blog V iewer
B log Adm in App
This Is The «Email-to-blog» System Architecture
Database AccessObjects
PostgreSQLdatabase
Mailbox
MailboxW atcher
P O P 3
BlogBean
MessageBean
AuthorBean
JSP-basedW eb-App
JD B C
B log U ser
H TTP
B log A dm in
H TTP
S M TP
Blog V iewer
B log Adm in App
Let’s Consider How It Works
Database AccessObjects
PostgreSQLdatabase
Mailbox
MailboxW atcher
P O P 3
BlogBean
MessageBean
AuthorBean
JSP-basedW eb-App
JD B C
B log U ser
H TTP
B log A dm in
H TTP
S M TP
Blog V iewer
B log Adm in App
1. How the Blog User posts a message to Blog
Blog User composes an email message and sends it to a special email address, for instance to<[email protected]>Each blog has its own pre-defined email addressbut all the blog messages are forwarded to the same physical mailbox.
Database AccessObjects
PostgreSQLdatabase
Mailbox
MailboxW atcher
P O P 3
BlogBean
MessageBean
AuthorBean
JSP-basedW eb-App
JD B C
B log U ser
H TTP
B log A dm in
H TTP
S M TP
Blog V iewer
B log Adm in App
1. How the Blog User posts a message to Blog
››››
From: <[email protected]>To: <[email protected]>Subject: My first blog…
Database AccessObjects
PostgreSQLdatabase
Mailbox
MailboxW atcher
P O P 3
BlogBean
MessageBean
AuthorBean
JSP-basedW eb-App
JD B C
B log U ser
H TTP
B log A dm in
H TTP
S M TP
Blog V iewer
B log Adm in App
1. How the Blog User posts a message to Blog
›
MailboxWatcher is a Java class that continuously(every 30 sec) checks the mailbox for new messages via POP3 protocol.So, there is a new message in mailbox and MailboxWatcher will detect it soon and start to process it.
Database AccessObjects
PostgreSQLdatabase
Mailbox
MailboxW atcher
P O P 3
BlogBean
MessageBean
AuthorBean
JSP-basedW eb-App
JD B C
B log U ser
H TTP
B log A dm in
H TTP
S M TP
Blog V iewer
B log Adm in App
1. How the Blog User posts a message to Blog
›
Database AccessObjects
PostgreSQLdatabase
Mailbox
MailboxW atcher
P O P 3
BlogBean
MessageBean
AuthorBean
JSP-basedW eb-App
JD B C
B log U ser
H TTP
B log A dm in
H TTP
S M TP
Blog V iewer
B log Adm in App
1. How the Blog User posts a message to Blog
›So, MailboxWatcher has dowloaded the message.Now it has to perform a series of checks.
Database AccessObjects
PostgreSQLdatabase
Mailbox
MailboxW atcher
P O P 3
BlogBean
MessageBean
AuthorBean
JSP-basedW eb-App
JD B C
B log U ser
H TTP
B log A dm in
H TTP
S M TP
Blog V iewer
B log Adm in App
1. How the Blog User posts a message to Blog
›1) Is the recipient email address ("To:" or "Cc:" header of the message) associated with a blog?
MailboxWatcher uses BlogBean.getBlogIdByEmail(email) method in order to check this condition. If the method has returned -1, the email address is not associated with a blog. In this case the message is being skipped.
Database AccessObjects
PostgreSQLdatabase
Mailbox
MailboxW atcher
P O P 3
BlogBean
MessageBean
AuthorBean
JSP-basedW eb-App
JD B C
B log U ser
H TTP
B log A dm in
H TTP
S M TP
Blog V iewer
B log Adm in App
1. How the Blog User posts a message to Blog
›BlogBean.getBlogIdByEmail(email) performs a database query:SELECT ID FROM BLOGS WHERE LOWER(EMAIL)=‘comments@…
Blog ID=1
And finds out that the associated blog ID = 1So, the returned value is 1.
Database AccessObjects
PostgreSQLdatabase
Mailbox
MailboxW atcher
P O P 3
BlogBean
MessageBean
AuthorBean
JSP-basedW eb-App
JD B C
B log U ser
H TTP
B log A dm in
H TTP
S M TP
Blog V iewer
B log Adm in App
1. How the Blog User posts a message to Blog
›2) Is the sender allowed to post messages to the specific blog (Blog ID = 1)?
MailboxWatcher performs 3 kinds of tests in order to check this condition.
Database AccessObjects
PostgreSQLdatabase
Mailbox
MailboxW atcher
P O P 3
BlogBean
MessageBean
AuthorBean
JSP-basedW eb-App
JD B C
B log U ser
H TTP
B log A dm in
H TTP
S M TP
Blog V iewer
B log Adm in App
1. How the Blog User posts a message to Blog
›2.1. Is the exact sender’s email address ("From:" header of the message) listed in the "authorized users" table for this Blog?
Database AccessObjects
PostgreSQLdatabase
Mailbox
MailboxW atcher
P O P 3
BlogBean
MessageBean
AuthorBean
JSP-basedW eb-App
JD B C
B log U ser
H TTP
B log A dm in
H TTP
S M TP
Blog V iewer
B log Adm in App
1. How the Blog User posts a message to Blog
›AuthorBean.getAuthorByEmail(email) performs a database query:SELECT ID,NAME FROM AUTHORS WHERE LOWER(EMAIL)=‘[email protected] finds out that the sender is in the database.
Now it’s time to check if the sender is allowed to post messages to the blog.MailboxWatcher calls blog.isAuthorAllowed(sender) method to check this condition.
Allowed
Database AccessObjects
PostgreSQLdatabase
Mailbox
MailboxW atcher
P O P 3
BlogBean
MessageBean
AuthorBean
JSP-basedW eb-App
JD B C
B log U ser
H TTP
B log A dm in
H TTP
S M TP
Blog V iewer
B log Adm in App
1. How the Blog User posts a message to Blog
›2.2. If the exact sender’s email address is NOT listed in the "authorized users" table for this Blog, then MailboxWatcher will try to find so-called domain-wideuser (a email address like "@host.com") in the table.The existence of the domain-wide user allows to post messages from any email address that belongs to the appropriate domain.
Database AccessObjects
PostgreSQLdatabase
Mailbox
MailboxW atcher
P O P 3
BlogBean
MessageBean
AuthorBean
JSP-basedW eb-App
JD B C
B log U ser
H TTP
B log A dm in
H TTP
S M TP
Blog V iewer
B log Adm in App
1. How the Blog User posts a message to Blog
›2.3. If the domain-wide email address is NOT listed in the "authorized users" table for this Blog, then MailboxWatcher will try to find so-called PUBLICuser in the table for the blog. The existence of PUBLIC user allows to post messages from any email address.
Database AccessObjects
PostgreSQLdatabase
Mailbox
MailboxW atcher
P O P 3
BlogBean
MessageBean
AuthorBean
JSP-basedW eb-App
JD B C
B log U ser
H TTP
B log A dm in
H TTP
S M TP
Blog V iewer
B log Adm in App
1. How the Blog User posts a message to Blog
›If the sender is allowed (according to at least one of the 3 tests) to post messages, MailboxWatcher calls MessageBean.addMessage() method to store the message in database.