Source Code Cross Referenced for MailSenderPlugin.java in  » Portal » DLOG4J » dlog4j » util » mail » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » DLOG4J » dlog4j.util.mail 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  This program is free software; you can redistribute it and/or modify
003:         *  it under the terms of the GNU General Public License as published by
004:         *  the Free Software Foundation; either version 2 of the License, or
005:         *  (at your option) any later version.
006:         *
007:         *  This program is distributed in the hope that it will be useful,
008:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
009:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
010:         *  GNU Library General Public License for more details.
011:         *
012:         *  You should have received a copy of the GNU General Public License
013:         *  along with this program; if not, write to the Free Software
014:         *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
015:         */
016:        package dlog4j.util.mail;
017:
018:        import java.util.Date;
019:
020:        import javax.servlet.ServletException;
021:
022:        import org.apache.struts.action.ActionServlet;
023:        import org.apache.struts.action.PlugIn;
024:        import org.apache.struts.config.ModuleConfig;
025:
026:        /**
027:         * 邮件发送的插件
028:         * 该插件在struts-config.xml中的配置如下
029:         <plug-in className="dlog4j.util.mail.MailSenderPlugin">
030:         <!-- 发件人邮件地址 -->
031:         <set-property property="mail" value="[email]"/>
032:         <!-- SMTP服务器地址 -->
033:         <set-property property="host" value="[smtp_server_addr]"/>
034:         <!-- SMTP服务器端口,如果不指定则使用默认25 -->
035:         <set-property property="port" value="25"/>
036:         <!-- 邮件帐号 -->
037:         <set-property property="username" value="[account]"/>
038:         <!-- 邮件密码 -->
039:         <set-property property="password" value="[password]"/>
040:         </plug-in>	
041:         * @author Winter Lau
042:         */
043:        public class MailSenderPlugin extends Mailer implements  PlugIn {
044:
045:            protected String mail;
046:            protected String host;
047:            protected int port = 25;
048:            protected String username;
049:            protected String password;
050:
051:            private ActionServlet servlet;
052:
053:            /* (non-Javadoc)
054:             * @see org.apache.struts.action.PlugIn#init(org.apache.struts.action.ActionServlet, org.apache.struts.config.ModuleConfig)
055:             */
056:            public void init(ActionServlet servlet, ModuleConfig config)
057:                    throws ServletException {
058:                this .servlet = servlet;
059:                mailer = this ;
060:            }
061:
062:            /**
063:             * 邮件发送
064:             * @param mails
065:             * @param title
066:             * @param content
067:             * @param isHtml
068:             */
069:            public void send(final String sendername, final String[] mails,
070:                    final String title, final String content) {
071:                new Thread() {
072:                    public void run() {
073:                        MailSender sender = MailSender.getHtmlMailSender(host,
074:                                port, username, password);
075:                        try {
076:                            sender.setSubject(title);
077:                            sender.setSendDate(new Date());
078:                            sender.setMailFrom(mail, sendername);
079:                            sender.setMailContent(content);
080:                            sender.setMailTo(mails, "to");
081:                            sender.sendMail();
082:                        } catch (Exception e) {
083:                            servlet.log("发送邮件失败,title=" + title
084:                                    + ",content=" + content, e);
085:                        }
086:                    }
087:                }.start();
088:            }
089:
090:            /* (non-Javadoc)
091:             * @see org.apache.struts.action.PlugIn#destroy()
092:             */
093:            public void destroy() {
094:            }
095:
096:            public String getHost() {
097:                return host;
098:            }
099:
100:            public void setHost(String host) {
101:                this .host = host;
102:            }
103:
104:            public String getMail() {
105:                return mail;
106:            }
107:
108:            public void setMail(String mail) {
109:                this .mail = mail;
110:            }
111:
112:            public String getPassword() {
113:                return password;
114:            }
115:
116:            public void setPassword(String password) {
117:                this .password = password;
118:            }
119:
120:            public int getPort() {
121:                return port;
122:            }
123:
124:            public void setPort(int port) {
125:                this .port = port;
126:            }
127:
128:            public String getUsername() {
129:                return username;
130:            }
131:
132:            public void setUsername(String username) {
133:                this.username = username;
134:            }
135:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.