email-to-blog how it works. this is the «email-to-blog» system architecture

16
Email-to- Blog How It Works

Upload: erick-jefferson

Post on 19-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Email-to-Blog How It Works. This Is The «Email-to-blog» System Architecture

Email-to-Blog

How It Works

Page 2: Email-to-Blog How It Works. 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

This Is The «Email-to-blog» System Architecture

Page 3: Email-to-Blog How It Works. 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

Page 4: Email-to-Blog How It Works. 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

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.

Page 5: Email-to-Blog How It Works. 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

1. How the Blog User posts a message to Blog

››››

From: <[email protected]>To: <[email protected]>Subject: My first blog…

Page 6: Email-to-Blog How It Works. 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

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.

Page 7: Email-to-Blog How It Works. 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

1. How the Blog User posts a message to Blog

Page 8: Email-to-Blog How It Works. 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

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.

Page 9: Email-to-Blog How It Works. 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

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.

Page 10: Email-to-Blog How It Works. 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

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.

Page 11: Email-to-Blog How It Works. 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

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.

Page 12: Email-to-Blog How It Works. 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

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?

Page 13: Email-to-Blog How It Works. 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

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

Page 14: Email-to-Blog How It Works. 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

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.

Page 15: Email-to-Blog How It Works. 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

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.

Page 16: Email-to-Blog How It Works. 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

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.