Support > Repository > Sending and receiving e-mail > Receive mail (time specified by job)
ja | en

You can receive mail by time designation. Analyze the mail body and register it as data.

Example Preparing an order model

Here, we prepare a model "order" to store received mail.The red frame in Figure 1 is prepared to capture the received mail.

"Sender" "addressee" "Cc registration destination" is "Use as repetition"Setting.

Figure 1 Order model

Setting of receiving mail

Open the "Mail> Receive" tab from the menu.Details of setting are as follows.

Fig. 2 Mail reception setting field

job

item Description Input example
Job name For this application system as a whole, specify a non-overlapping job name (English). InsertOrderFromMailJob
Description Please write freely. -
Start condition After converting the imported mail into a model, you can specify the conditions for importing.The standard is blank (no condition).Items concerning the target model are expressed as "$ {" + (item name) + "}".functionYou can also use.
(However, even if this condition is met, if an error occurs in the input check, it will not be taken in again.That is, if both the start condition and the input check are positive, they are newly registered in the database.)
If you set the subject of the mail to the subject field, only those whose subject starts with "Wagby" are registered:
FIND("Wagby", ${subject})==1
Action on success Specify processing to be performed after mail reception succeeds.Items concerning the target model are expressed as "$ {" + (item name) + "}".functionYou can also use.You can also specify an assignment statement using "=".
When this designation is done, it executes the specified processing and then writes to the database.Therefore, if writing to the database fails for any reason, both the captured mail and the action on success will be invalid.
Allowed sender address Specify the sender's address.It is specified by exact match.You can specify a pattern match by regular expressions. .*@jasminesoft.co.jpBy writing it, you will be able to retrieve only the mail address whose domain name is jasminesoft.co.jp.
Attachment registration destination Register the file attached to the received mail Specify the item name (of this model).Please make this item file name type.If there are multiple attachments, define them as repeating containers. For example, if you have prepared a file type item filename in the repeating container attachments,attachments/filenameI write it.

Mail Server

item Description Input example (when using Gmail)
Mail Server Specify the mail server name.You can add ": (colon)" after the mail server name and specify an arbitrary port number. pop.gmail.com:995
account name Specify the mail account for receiving. YOURNAME@gmail.com
password Specify the password for reception.
protocol You can select either POP3, IMAP, POP3 over SSL, or IMAP over SSL.When not selected, it becomes POP 3. POP3 over SSL
APOP authentication To use APOP authentication, enable the check box. (Do not check in Gmail)

Destination Details

item Description Supplement
subject Specify the item name (of this model) to which the value of the subject (Subject) of the received mail is posted.If this value is blank, subject information information is ignored. Please make it a character string type.
From Specify the item name (of this model) to which the value of the sender (From) of the received mail is posted.If this value is blank, the sender's information is ignored. Please specify repeat with character string type (mail address attribute).
There are many cases of one person in the sender, but Internet mail specifications allow you to handle multiple people.Wagby also conforms to this specification.
Recipient Specify the item name (of this model) to which the value of the recipient (To) of the received mail is posted.If this value is blank, the recipient's information is ignored. Please specify repeat with character string type (mail address attribute).
CC Specify the item name (in this model) to which the value of carbon copy (CC) of incoming mail is posted.If this value is blank, CC information is ignored. Please specify repeat with character string type (mail address attribute).
Sent date Specify the item name (of this model) to which the value of the transmission date of the received mail is posted.When this value is blank, information on the transmission date is ignored. Must be date type/date time type/time type.
Text Specify the item name (of this model) to which the value of the body (BODY) of the received mail is posted.If this value is blank, information in the body is ignored. Please make it a character string type.When recording a large number of character strings,textareaWe recommend to use.

Automatic text analysis function

item Description initial value
To enable When this column is checked, the body of received mail is automatically analyzed and values ​​are set for each item of the model.(Described later)
Starting delimiter of value part When the body automatic analysis function is enabled, you can specify the start delimiter of the value part. When unspecified, it becomes "Half Space".
End of delimiter for value part When automatic analysis function of text is enabled, you can specify the end delimiter of the value part. When not specified, it becomes "line feed".
target items When you enable automatic analysis function of text, specify analysis target item. When not specified, all items are eligible.
Handling of delimiters When automatic analysis function of text is enabled, specify whether to ignore double-byte/half-width character divisions of start delimiter and ending delimiter. When not specified, double-byte characters and half-width characters are distinguished.

Job dedicated account jobadmin setting

"Support> Administrator Guide>Preparation: Enable job execution accountFollow the instructions in "Activate jobadmin account".

It is necessary to give the jobadmin account the operation authority (principal) of the target model for sending mail.In the example shown in Fig. 4, it is an example of granting "general user" principal.

Figure 3 Setting up jobadmin account

Schedule setting

We will register a new job schedule.

  1. Log on with an account with administrator privileges.
  2. Open the "Job Management" "Job Schedule Search" screen from the menu.
  3. Click the "Register Screen" button to register a new job schedule.
  4. From the job name, select the job name set in Figure 1.(Fig. 5) * If you can not select a job name, please read the notes in the lower column of Fig.
  5. Specify scheduleTo do.
  6. Check the "valid" flag.
  7. Enter the account "jobadmin" to run this job.
  8. Register the job schedule.The command will be executed at the specified time.
Fig. 4 New registration of schedule

When job name can not be selected

If you can not select the job name in step 4 above, you may have imported all the old data after the build.The added job is prepared as a "job master" model, and the export data is described in the "data_init" folder after the build, but it does not exist in the old data.Therefore, the job information is old data at the timing when the old data is imported.

As a countermeasure, after importing the old data, import the "data_init" folder to the import folder name again and import "model list provided by the system> job master" again.This will make it possible to recognize (added) jobs.

Interval of mail reception

Make sure to execute the mail reception function at regular intervals.Executing the reception function continuously in a short time increases the load on the mail server and the application server on which Wagby operates.Depending on the mail server, it may be interpreted as a security attack and the reception from this account may be stopped.

Figure 5 shows an example of mail being imported by a job.

Fig. 5 Mail reception

The following record remains in the log file (logs/system.log).

2014-10-01 14:33:00 [INFO jp.jasminesoft.jfc.JFCJobTriggerListener triggerFired] (LOGONUSER@localhost) JFC-00902:ジョブ InsertOrderFromMailJob を開始しました。
2014-10-01 14:33:00 [INFO jp.jasminesoft.jfc.LogonStatusManager addUserName] (LOGONUSER@localhost) JFC-90000:アカウント jobadmin がセッションに追加されました。現在の同時接続数は 1 で、合計セッション数は 2 です。
2014-10-01 14:33:01 [INFO jp.jasminesoft.wagby.app.order.InsertOrderFromMailProcessor process] Folder opened
2014-10-01 14:33:01 [INFO jp.jasminesoft.wagby.app.order.InsertOrderFromMailProcessor process] Total mail count: 1
2014-10-01 14:33:01 [INFO jp.jasminesoft.wagby.app.order.InsertOrderFromMailProcessor process] _mcount: 1
2014-10-01 14:33:02 [INFO jp.jasminesoft.wagby.app.order.InsertOrderFromMailProcessor process] Message-ID: <75F5BB63-D2CC-47F1-A004-6E0982C7E865@YOURDOMAIN.co.jp>
2014-10-01 14:33:03 [INFO jp.jasminesoft.wagby.app.order.InsertOrderFromMailProcessor process] Folder closed
2014-10-01 14:33:03 [INFO jp.jasminesoft.jfc.job.JFCBaseJobBean executeInternal] (jobadmin@localhost)1 mail is processed.
2014-10-01 14:33:03 [INFO jp.jasminesoft.jfc.User logoff] (LOGONUSER@localhost) JFC-00028:アカウント jobadmin のログオフを行います。
2014-10-01 14:33:03 [INFO jp.jasminesoft.jfc.LogonStatusManager removeUserName] (LOGONUSER@localhost) JFC-90003:アカウント jobadmin がセッションから除かれました。現在の同時接続数は 0 で、合計セッション数は 0 です。
2014-10-01 14:33:03 [INFO jp.jasminesoft.jfc.JFCJobTriggerListener triggerComplete] (LOGONUSER@localhost) JFC-00900:ジョブ InsertOrderFromMailJob は正常に終了しました。

If you set the mail body to the prescribed format, the application will automatically parse the contents of the mail body and set the value in each item.

Write the mail body in the following format.

  • Describe the item name and value on one line.
  • For item name, use "item name (Japanese)".
  • Place a space character as a delimiter between item name and value.(Half space characters after the second line on each line are treated as part of the value.)

For example, for a model that has items such as "Name" "Address" "Telephone" (these are all "item names"), the body of the mail is described as follows.

Name Yamada Taro Address Okinawa Telephone 098-000-0001

You can also specify start and end delimiters for values.For example, if you specify "<" as the start delimiter and ">" as the ending delimiter, you can parse the following body of the mail.

Name <Taro Yamada> Address <Okinawa Prefecture> Telephone <098-000-0001> Remarks <You can also store sentences with newlines.>

Detailed rules of this function are as follows.

  • "1 character" can be specified as the start delimiter and ending delimiter.
  • If you specify a character other than a space character in the start delimiter, you can parse even if the item name contains a space.
  • If you specify a character other than line break as the end delimiter character, you can parse even if the mail body contains blanks and line feeds.
  • Even when extra spaces are included in front of item names, analysis processing will be done correctly.
  • Model reference items are also supported.In this case please write "value" (content part), not code.
  • Automatic calculation and reference interlocking resolution processing are also performed after the body analysis processing.
  • When "registration destination of ~" is specified in the "mail reception setting" definition, the value of the item takes precedence over the "body of registration of ~" from the mail body analysis result.For example, if the "subject" item is specified as the "subject name registration destination", even if the value is set in the subject item in the mail body analysis, the value of the item specified in the "subject registration destination" It will be overwritten.

When receiving HTML mail, the item storing body isText area (rich)Replace the new line character with __.

Details

HTML mail consists of text part and HTML part.Wagby's mail reception uses the text part.Replace the new line character in the text portion with __.

This text portion does not necessarily match the new line character in the HTML portion.Handling varies depending on your mail software.As a result, a line feed in a rich text area may appear in a position different from the line break of the HTML part.If you have any doubts, please confirm the new line character of "text part" of the imported mail.

The following parameters can be set.

The job parameter takes precedence over the value specified by Wagby Desinger.You can change mail recipients etc during operation.
Parameter name Description Description example
mailhost Mail host mail.yourdomain.com
username Account to receive mail yamada
password Password of account to receive mail
protocol protocol pop3
pop3s
APOP Usage of APOP authentication true
analyzeBody Enable and disable automatic analysis function of text true
dataStartChar Starting delimiter of value part [
dataEndChar End of delimiter for value part ]
debug Enable debug mode. Information on mailhost, username, password is displayed in system.log.You can check whether the mail server is being accessed with the set information. true
removeErrorMail Also delete mails with errors in the middle of processing from the mail server. true
JavaMailDebug A detailed log is output each time a job is executed.[More ...] true

You can temporarily disable the job.

  1. Log on with an account with administrator privileges.
  2. Open the "Job" "Job Schedule Search" screen from the menu.
  3. Search the applicable "Job Schedule" and open the maintenance screen.
  4. Uncheck the "Enabled" flag and save it.
Figure 6 Disable job

You can send the job execution result by e-mail.

Multiple job execution can not be performed.

If you make a job start every minute, if execution of this job is not completed in 1 minute, a new job will not be executed.

You can also register passwords by receiving e-mails for the juser model. Please add the item "New password" to the mail body.

  • This function continues to receive mail at specified intervals while the job is running.These emails will be "Received (Read)".You can not return this to an unreceived state.Also, it can not be said that it does not receive it depending on conditions.
  • Conditional rights management with reference to item valuesYou can not set.The expression of authority management uses the value of the store model, but when receiving mail, the store model is empty.If you need to use conditional rights management in processing from the screen, please define a submodel for receiving mail and use together.

If the mail reception function does not work, please confirm the following points.

Check whether the job has been activated

System log browsing screen of management processing menuThen you can confirm by doing the next search.

[Search condition] Type: INFO keyword: JFC-00902

I try to receive mail at intervals of N minutes but it does not start

In the job schedule setting, does the value "hour" include a numeric value (eg 0)?In this case, it means only to start at 0 o'clock.By solving the "hour" part as "*" we solve it.

Mail reception may fail

(1) Is the mail reception interval too short?Reception will fail if the next job starts up even though the previous job has not ended.Or, frequent mail reception may be misrecognized as a security attack on the mail server side.

(2) Are multiple mail reception jobs registered?If multiple mail receiving jobs of different types access the same mailbox at the same time, the job started later fails to receive.

A database write error occurs

In general, the mail body is a long text string.When importing the text, saving errors may occur due to restriction of the storage area of ​​the character string in the standard "character string type" of the database.This is logged as an error in the operation log file (logs/system.log).

In this case, it is a good idea to separately specify "type that can store long text strings" provided by your database.For example, when using PostgreSQL as a database,You can save up to 1 GB of character string by specifying "text"It will look like.

Or Wagby'sString handling functionThere is also an idea to save cuts with the specified character string length using.

An error occurs with the same mail reading every time

Every time an incoming job is executed, a reception error occurs every time an error occurs due to some reason. If there is a mail that becomes a reception error, please delete the corresponding mail from the mailbox by another mail software etc.

However, the cause of the e-mail that becomes a reception error every time is in the design of the model.In most cases, you can fix it by reviewing the definition.For example, it is as follows.

  • Mismatch of data type and item type to be captured
  • Duplicate values ​​are set for items with unique constraints
  • Data is not set in required item

Attachment processing may fail

This phenomenon may occur when the file name of the attached file contains Japanese characters.

For example, the mail server performs some processing on the file name including Japanese, and embeds characters that the Windows OS can not handle, such as "?" In the file name.Wagby tries to save the file using that file name, but since the Windows OS handles this as an error, the mail reception process fails.

In such a case change the file name (attached to the mail) or change the "string - file> Handling of saved file name"," Use original file name as it is "Do not selectwill do so.

Acquire detailed log

Job parameters JavaMailDebug true By doing so, you can get a detailed log of the reception status.The file names are as follows.

Javamail-Insert <model ID> FromMailProcessor-yyyyMMdd_HHmmss.log

For example, a log file "javamail - InsertModel 1 FromMailProcessor - 20150624 - 194742.log" is prepared when executing the mail reception job of model Model 1.The contents of the log are as follows.

DEBUG: getProvider() returning javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc]
DEBUG POP3: connecting to host "YOURMAILSERVER", port 995, isSSL true
S: +OK Dovecot ready. <73b1.e.5583d560.2eAI44Sem3e4iVvBMeQCaQ==@XXX.jasminesoft.co.jp>
C: USER [※ユーザ名]
S: +OK
C: PASS [※パスワード]
S: +OK Logged in.
C: STAT
S: +OK 2836 266374220
C: NOOP
S: +OK
C: TOP 1 0
S: +OK
Return-Path: <yamada@jasminesoft.co.jp>
X-Original-To: who@jasminesoft.co.jp
Delivered-To: who@jasminesoft.co.jp
Received: from XXX.jasminesoft.co.jp (localhost [127.0.0.1])
....
Sender: suzuki@jasminesoft.co.jp
Errors-To: adm@jasminesoft.co.jp

.
C: QUIT
S: +OK Logging out.

User name and password for POP authentication are entered in [* user name] and [※ password].Also, the contents of all received mails are output.Since personal information is contained in a lot like this, please handle with care.Please do not output this log except for debugging purpose in development.