Use a MAILET to process mail

xiaoxiao2021-03-06  40

The MAILET API is a simple API for creating a mail handler, which is configured in the interface server-side interface, and the matching of the MAILET, the match is matched according to a specific condition, and triggered the response MAILET. This word is similar to the servlet. It is similar to the function. Their common situations are triggered and executed in the server side, just servlet's Matcher is usually a URL's Pattern, just like the servlet, MAILET also has init () method, service, service Methods and Destroy methods. That is, they all have similar life cycles. Simple programmable interfaces for MAILET can be used to do some email processing, such as anti-spam, check mail viruses, and mail blogs, using mobile devices to send Email features It can be used to send information to the mail server to the mail server. The mobile blog is handed over to the mail server. Below is a small hello world MAILET code: package com.gdsean; import org.apache.mailet. *; Public class hellomailet extends GenericMailet {public void init () throws MessagingException {} public void service (mail mail) throws MessagingException {System.out.println ( "hello world");}} package com.gdsean; public class HelloMatcher extends GenericRecipientMatcher {public boolean matchRecipient (Maildress Recipient) {// mail address must contain Hello's if (Recipient.getuser (). IndexOf ("Hello")! = - 1) {Return true;} Return False;}

} The next step is configured to configure the code to perform the James Mail Server that performs Mailet, find the James-2.2.0 / apps / James / SAR-INF / Config.xml ... Join package com.gdsean org.apache.james.transport.matchers package com.gdsean If your domain name is Test.com, send an email to helloworld@ Test.com, and Mailet will in the background. Output "Hello World".

转载请注明原文地址:https://www.9cbs.com/read-54366.html

New Post(0)