EMailRobot
[ home ] | [ info ] | [ demo ] | [ downloads ] | [ documentation ] | [ description ]
| info | ||||||||||||||
|
| downloads | |
|
| demo |
You can to see email robot in action, by follow:
send email to demo1 address with
follow body (2 lines as plain text):
$a: 1 $b: 2if all ok, you will get answer from robot ( a + b ): 1 + 2 = 3 |
| documentation |
AboutThis is simple framework for handle emails by some robot, perform some action based on params extracted from email body, and generate answer email with some result. DemoYou can to see email robot in action, by follow: send email to demo1 address with follow body (2 lines as plain text): $a: 1 $b: 2 if all ok, you will get answer from robot: 1 + 2 = 3 I.e. robot:
Files, directories
When you unzip archive, you'll found follow structure:
EMailRobot03/
bin/
include/
test/
readme.txt
'bin' -- here is placed 'robot.php' script for what need to configure email pipe 'include' -- here are placed all classes 'test' -- here you can to test system without sending and getting emails, just start 'test.php' from console, and it handle 'email.txt' file as input email message, and prints result of action to console. About email pipeWhen you send email to demo1@... it will arrive to computer where 'emailrobot.elementalcms.org' domain is placed, then come to some email-daemon programm, and this programm have to see to some 'aliaces' or 'email forwarding' file, in this file email-daemon have to find the rule for 'demo1' name. In this example in file there is 'pipe'-rule, this rule mean - "all incoming email messages need to pass to script what is specified in pipe". I.e. on left side of the pipe will be email message on right side - runing script. How to configure I have cPanel admin for manage my account, and there in:
"Email Management Tools / Aliases/Forwarding", I've "Add Forwarder", with
name 'demo1', and in field for forwarding set:
How it worksIn 'robot.php' file the script read all 'stdin' stream and pass it to email robot object, and then run 'work' method what will do all work: $stdin = file( "php://stdin" ); $m = implode( "", $stdin ); $e_robot = new EMailRobot(); $e_robot->setEMailData( $m ); $e_robot->work(); EMailRobot classThis is main class, see EMailRobot/EMailRobot.php for detail explanation. There is 'Message' and 'Action' abstract classes. Message classThe purpose of 'Message' class is parse text, and extract pairs: 'name1': 'value1', 'name2': 'value2', etc. This class have 2 public functions:
- setData( $data ):
initialize Message class by text
- getField( $name ):
get field named '$name'
abstract: - parse() - parse $data, and initialize pairs (params) private: - setField( $name, $value ) - called from 'parse' For example see 'MessageFormat1.php' this class implement 'parse' method for parse follow format: $param_name1:param_value1 $param_name2:param_value2 ... Action classPurpose of 'Action' class is to make some action based on params (this class have access to 'Message' object), and set result. Have public methods:
- setMessage( &$message ):
set object of 'Message' class (parsed email-body)
- getResult():
returns result of action
Abstract method:
- make():
any action based on 'Message' object
In this demo there is 2 action classes:
The EMailRobot class configured to 'ActionSum.php' you can to configure to ActionMult.php class -- see 'EMailRobot/EMailRobot.php' file lines 81-83. |
| description | ||||||||||||||||||
|
UML diagrams for product classes overview.
Use Case diagram
|