Java Doc for EmailService.java in  » Net » openfire » org » jivesoftware » util » 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 » Net » openfire » org.jivesoftware.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.jivesoftware.util.EmailService

EmailService
public class EmailService (Code)
A service to send email.

This class has a few factory methods you can use to return message objects or to add messages into a queue to be sent. Using these methods, you can send emails in the following couple of ways:

 EmailService.sendMessage(
 "Joe Bloe", "jbloe@place.org",
 "Jane Doe", "jane@doe.com",
 "Hello...",
 "This is the body of the email...",
 null
 );
 
or
 Message message = EmailService.createMimeMessage();
 // call setters on the message object
 // .
 // .
 // .
 emailService.sendMessage(message);
 

This class is configured with a set of Jive properties:

  • mail.smtp.host -- the host name of your mail server, i.e. mail.yourhost.com. The default value is "localhost".
  • mail.smtp.port -- an optional property to change the smtp port used from the default of 25.
  • mail.smtp.username -- an optional property to change the username used to connect to the smtp server. Default is no username.
  • mail.smtp.password -- an optional property to change the password used to connect to the smtp server. Default is no password.
  • mail.smtp.ssl -- an optional property to set whether to use SSL to connect to the smtp server or not. Default is false.
  • mail.debugEnabled -- true if debug information should written out. Default is false.




Method Summary
public  MimeMessagecreateMimeMessage()
     Factory method to return a blank JavaMail message.
public  StringgetHost()
     Returns the SMTP host (e.g.
public static  EmailServicegetInstance()
    
public  StringgetPassword()
     Returns the password used to connect to the SMTP server.
public  intgetPort()
     Returns the port number used when connecting to the SMTP server.
public  StringgetUsername()
     Returns the username used to connect to the SMTP server.
public  booleanisDebugEnabled()
     Returns true if SMTP debugging is enabled.
public  booleanisSSLEnabled()
     Returns true if SSL is enabled for SMTP connections.
public  voidsendMessage(MimeMessage message)
     Sends a JavaMail message.
public  voidsendMessage(String toName, String toEmail, String fromName, String fromEmail, String subject, String textBody, String htmlBody)
     Sends a message, specifying all of its fields.

To have more advanced control over the message sent, use the EmailService.sendMessage(MimeMessage) method.

Both a plain text and html body can be specified.

public  voidsendMessages(Collection<MimeMessage> messages)
     Send a collection of messages.
public  voidsendMessagesImmediately(Collection<MimeMessage> messages)
     Sends a collection of email messages.
public  voidsetDebugEnabled(boolean debugEnabled)
     Enables or disables SMTP transport layer debugging.
public  voidsetHost(String host)
     Sets the SMTP host (e.g.
public  voidsetPassword(String password)
     Sets the password that will be used when connecting to the SMTP server.
public  voidsetPort(int port)
     Sets the port number that will be used when connecting to the SMTP server.
public  voidsetSSLEnabled(boolean sslEnabled)
     Sets whether the SMTP connection is configured to use SSL or not.
public  voidsetUsername(String username)
     Sets the username that will be used when connecting to the SMTP server.



Method Detail
createMimeMessage
public MimeMessage createMimeMessage()(Code)
Factory method to return a blank JavaMail message. You should use the object returned and set desired message properties. When done, pass the object to the addMessage(Message) method. a new JavaMail message.



getHost
public String getHost()(Code)
Returns the SMTP host (e.g. mail.example.com). The default value is "localhost". the SMTP host.



getInstance
public static EmailService getInstance()(Code)



getPassword
public String getPassword()(Code)
Returns the password used to connect to the SMTP server. If the password is null, no password will be used when connecting to the server. the password used to connect to the SMTP server, or null ifthere is no password.



getPort
public int getPort()(Code)
Returns the port number used when connecting to the SMTP server. The default port is 25. the SMTP port.



getUsername
public String getUsername()(Code)
Returns the username used to connect to the SMTP server. If the username is null, no username will be used when connecting to the server. the username used to connect to the SMTP server, or null ifthere is no username.



isDebugEnabled
public boolean isDebugEnabled()(Code)
Returns true if SMTP debugging is enabled. Debug information is written to System.out by the underlying JavaMail provider. true if SMTP debugging is enabled.



isSSLEnabled
public boolean isSSLEnabled()(Code)
Returns true if SSL is enabled for SMTP connections. true if SSL is enabled.



sendMessage
public void sendMessage(MimeMessage message)(Code)
Sends a JavaMail message. To create a message, use the EmailService.createMimeMessage() method.
Parameters:
  message - the message to send.



sendMessage
public void sendMessage(String toName, String toEmail, String fromName, String fromEmail, String subject, String textBody, String htmlBody)(Code)
Sends a message, specifying all of its fields.

To have more advanced control over the message sent, use the EmailService.sendMessage(MimeMessage) method.

Both a plain text and html body can be specified. If one of the values is null, only the other body type is sent. If both body values are set, a multi-part message will be sent. If parts of the message are invalid (ie, the toEmail is null) the message won't be sent.
Parameters:
  toName - the name of the recipient of this email.
Parameters:
  toEmail - the email address of the recipient of this email.
Parameters:
  fromName - the name of the sender of this email.
Parameters:
  fromEmail - the email address of the sender of this email.
Parameters:
  subject - the subject of the email.
Parameters:
  textBody - plain text body of the email, which can be null if thehtml body is not null.
Parameters:
  htmlBody - html body of the email, which can be null if the text bodyis not null.




sendMessages
public void sendMessages(Collection<MimeMessage> messages)(Code)
Send a collection of messages. To create a message, use the EmailService.createMimeMessage() method.
Parameters:
  messages - a collection of the messages to send.



sendMessagesImmediately
public void sendMessagesImmediately(Collection<MimeMessage> messages) throws MessagingException(Code)
Sends a collection of email messages. This method differs from EmailService.sendMessages(Collection) in that messages are sent before this method returns rather than queueing the messages to be sent later.
Parameters:
  messages - the messages to send.
throws:
  MessagingException - if an error occurs.



setDebugEnabled
public void setDebugEnabled(boolean debugEnabled)(Code)
Enables or disables SMTP transport layer debugging. Debug information is written to System.out by the underlying JavaMail provider.
Parameters:
  debugEnabled - true if SMTP debugging should be enabled.



setHost
public void setHost(String host)(Code)
Sets the SMTP host (e.g. mail.example.com). The default value is "localhost".
Parameters:
  host - the SMTP host.



setPassword
public void setPassword(String password)(Code)
Sets the password that will be used when connecting to the SMTP server. The default is null, or no password.
Parameters:
  password - the SMTP password.



setPort
public void setPort(int port)(Code)
Sets the port number that will be used when connecting to the SMTP server. The default is 25, the standard SMTP port number.
Parameters:
  port - the SMTP port number.



setSSLEnabled
public void setSSLEnabled(boolean sslEnabled)(Code)
Sets whether the SMTP connection is configured to use SSL or not. Typically, the port should be 465 when using SSL with SMTP.
Parameters:
  sslEnabled - true if ssl should be enabled, false otherwise.



setUsername
public void setUsername(String username)(Code)
Sets the username that will be used when connecting to the SMTP server. The default is null, or no username.
Parameters:
  username - the SMTP username.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.