Java Doc for Email.java in  » Net » apache-common-Email » org » apache » commons » 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 » Net » apache common Email » org.apache.commons.mail 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.commons.mail.Email

All known Subclasses:   org.apache.commons.mail.mocks.MockEmailConcrete,  org.apache.commons.mail.MultiPartEmail,  org.apache.commons.mail.SimpleEmail,
Email
abstract public class Email (Code)
The base class for all email messages. This class sets the sender's email & name, receiver's email & name, subject, and the sent date. Subclasses are responsible for setting the message body.
since:
   1.0
author:
   Quinton McCombs
author:
   Jon S. Stevens
author:
   Frank Y. Kim
author:
   Brett McLaughlin
author:
   Greg Ritter
author:
   Regis Koenig
author:
   Colin Chalmers
author:
   Matthias Wessendorf
author:
   Corey Scott
version:
   $Revision: 279295 $ $Date: 2005-09-07 12:56:41 +0200 (Wed, 07 Sep 2005) $
version:
   $Id: Email.java 279295 2005-09-07 10:56:41Z henning $


Field Summary
final public static  StringATTACHMENTS
    
final public static  StringCONTENT_TYPE
    
final public static  StringEMAIL_BODY
    
final public static  StringEMAIL_SUBJECT
    
final public static  StringFILE_SERVER
    
final public static  StringISO_8859_1
    
final public static  StringKOI8_R
    
final public static  StringMAIL_DEBUG
    
final public static  StringMAIL_HOST
    
final public static  StringMAIL_PORT
    
final public static  StringMAIL_SMTP_AUTH
    
final public static  StringMAIL_SMTP_FROM
    
final public static  StringMAIL_TRANSPORT_PROTOCOL
    
final public static  StringRECEIVER_EMAIL
    
final public static  StringRECEIVER_NAME
    
final public static  StringSENDER_EMAIL
    
final public static  StringSENDER_NAME
    
final public static  StringSMTP
    
final public static  StringTEXT_HTML
    
final public static  StringTEXT_PLAIN
    
final public static  StringUS_ASCII
    
protected  Authenticatorauthenticator
     Instance of an Authenticator object that will be used when authentication is requested from the mail server.
protected  ListbccList
    
protected  StringbounceAddress
     Address to which undeliverable mail should be sent.
protected  ListccList
    
protected  Stringcharset
    
protected  Objectcontent
    
protected  StringcontentType
    
protected  booleandebug
    
protected  MimeMultipartemailBody
    
protected  InternetAddressfromAddress
    
protected  Mapheaders
     Used to specify the mail headers.
protected  StringhostName
     The hostname of the mail server with which to connect.
protected  MimeMessagemessage
     The email message to send.
protected  booleanpopBeforeSmtp
     Used to determine whether to use pop3 before smtp, and if so the settings.
protected  StringpopHost
    
protected  StringpopPassword
    
protected  StringpopUsername
    
protected  ListreplyList
    
protected  DatesentDate
    
protected  StringsmtpPort
     The port number of the mail server to connect to.
protected  Stringsubject
    
protected  ListtoList
    


Method Summary
public  EmailaddBcc(String email)
     Add a blind BCC recipient to the email.
Parameters:
  email - A String.
public  EmailaddBcc(String email, String name)
     Add a blind BCC recipient to the email.
Parameters:
  email - A String.
Parameters:
  name - A String.
public  EmailaddCc(String email)
     Add a recipient CC to the email.
Parameters:
  email - A String.
public  EmailaddCc(String email, String name)
     Add a recipient CC to the email.
Parameters:
  email - A String.
Parameters:
  name - A String.
throws:
  EmailException - Indicates an invalid email address.
public  voidaddHeader(String name, String value)
     Adds a header ( name, value ) to the headers Map.
public  EmailaddReplyTo(String email)
     Add a reply to address to the email.
Parameters:
  email - A String.
public  EmailaddReplyTo(String email, String name)
     Add a reply to address to the email.
Parameters:
  email - A String.
Parameters:
  name - A String.
public  EmailaddTo(String email)
     Add a recipient TO to the email.
Parameters:
  email - A String.
throws:
  EmailException - Indicates an invalid email address.
public  EmailaddTo(String email, String name)
     Add a recipient TO to the email.
Parameters:
  email - A String.
Parameters:
  name - A String.
throws:
  EmailException - Indicates an invalid email address.
public  voidbuildMimeMessage()
     Build the internal MimeMessage to be sent.
public  InternetAddressgetFromAddress()
     Gets the sender of the email.
public  StringgetHostName()
    
public  SessiongetMailSession()
    
public  MimeMessagegetMimeMessage()
     Returns the internal MimeMessage.
public  DategetSentDate()
     Gets the sent date for the email.
public  StringgetSmtpPort()
     Gets the listening port of the SMTP server.
public  StringgetSubject()
     Gets the subject of the email.
public  Stringsend()
     Sends the email.
public  StringsendMimeMessage()
     Sends the previously created MimeMessage to the SMTP server.
public  voidsetAuthentication(String userName, String password)
     Sets the userName and password if authentication is needed.
public  voidsetAuthenticator(Authenticator newAuthenticator)
     Sets the Authenticator to be used when authentication is requested from the mail server.

This method should be used when your outgoing mail server requires authentication.

public  EmailsetBcc(Collection aCollection)
    
public  EmailsetBounceAddress(String email)
     Set the "bounce address" - the address to which undeliverable messages will be returned.
public  EmailsetCc(Collection aCollection)
     Set a list of "CC" addresses.
Parameters:
  aCollection - collection of InternetAddress objects.
public  voidsetCharset(String newCharset)
     Set the charset of the message.
public  voidsetContent(MimeMultipart aMimeMultipart)
    
public  voidsetContent(Object aObject, String aContentType)
    
public  voidsetDebug(boolean d)
     Setting to true will enable the display of debug information.
public  EmailsetFrom(String email)
     Set the FROM field of the email.
Parameters:
  email - A String.
public  EmailsetFrom(String email, String name)
     Set the FROM field of the email.
Parameters:
  email - A String.
Parameters:
  name - A String.
throws:
  EmailException - Indicates an invalid email address.
public  voidsetHeaders(Map map)
     Used to specify the mail headers.
public  voidsetHostName(String aHostName)
    
public  voidsetMailSession(Session aSession)
    
abstract public  EmailsetMsg(String msg)
     Define the content of the mail.
public  voidsetPopBeforeSmtp(boolean newPopBeforeSmtp, String newPopHost, String newPopUsername, String newPopPassword)
     Set details regarding "pop3 before smtp" authentication.
public  voidsetSentDate(Date date)
     Sets the sent date for the email.
public  voidsetSmtpPort(int aPortNumber)
     Set the port number of the outgoing mail server.
public  EmailsetSubject(String aSubject)
     Set the email subject.
Parameters:
  aSubject - A String.
public  EmailsetTo(Collection aCollection)
     Set a list of "TO" addresses.
Parameters:
  aCollection - collection of InternetAddress objects.
throws:
  EmailException - Indicates an invalid email address.
protected  InternetAddress[]toInternetAddressArray(List list)
     Utility to copy List of known InternetAddress objects into an array.
Parameters:
  list - A List.

Field Detail
ATTACHMENTS
final public static String ATTACHMENTS(Code)



CONTENT_TYPE
final public static String CONTENT_TYPE(Code)



EMAIL_BODY
final public static String EMAIL_BODY(Code)



EMAIL_SUBJECT
final public static String EMAIL_SUBJECT(Code)



FILE_SERVER
final public static String FILE_SERVER(Code)



ISO_8859_1
final public static String ISO_8859_1(Code)



KOI8_R
final public static String KOI8_R(Code)



MAIL_DEBUG
final public static String MAIL_DEBUG(Code)



MAIL_HOST
final public static String MAIL_HOST(Code)



MAIL_PORT
final public static String MAIL_PORT(Code)



MAIL_SMTP_AUTH
final public static String MAIL_SMTP_AUTH(Code)



MAIL_SMTP_FROM
final public static String MAIL_SMTP_FROM(Code)



MAIL_TRANSPORT_PROTOCOL
final public static String MAIL_TRANSPORT_PROTOCOL(Code)



RECEIVER_EMAIL
final public static String RECEIVER_EMAIL(Code)



RECEIVER_NAME
final public static String RECEIVER_NAME(Code)



SENDER_EMAIL
final public static String SENDER_EMAIL(Code)



SENDER_NAME
final public static String SENDER_NAME(Code)



SMTP
final public static String SMTP(Code)



TEXT_HTML
final public static String TEXT_HTML(Code)



TEXT_PLAIN
final public static String TEXT_PLAIN(Code)



US_ASCII
final public static String US_ASCII(Code)



authenticator
protected Authenticator authenticator(Code)
Instance of an Authenticator object that will be used when authentication is requested from the mail server.



bccList
protected List bccList(Code)
List of "bcc" email adresses



bounceAddress
protected String bounceAddress(Code)
Address to which undeliverable mail should be sent. Because this is handled by JavaMail as a String property in the mail session, this property is of type String rather than InternetAddress.



ccList
protected List ccList(Code)
List of "cc" email adresses



charset
protected String charset(Code)
The charset to use for this message



content
protected Object content(Code)
The content



contentType
protected String contentType(Code)
The content type



debug
protected boolean debug(Code)
Set session debugging on or off



emailBody
protected MimeMultipart emailBody(Code)
An attachment



fromAddress
protected InternetAddress fromAddress(Code)
The Address of the sending party, mandatory



headers
protected Map headers(Code)
Used to specify the mail headers. Example: X-Mailer: Sendmail, X-Priority: 1( highest ) or 2( high ) 3( normal ) 4( low ) and 5( lowest ) Disposition-Notification-To: user@domain.net



hostName
protected String hostName(Code)
The hostname of the mail server with which to connect. If null will try to get property from system.properties. If still null, quit



message
protected MimeMessage message(Code)
The email message to send.



popBeforeSmtp
protected boolean popBeforeSmtp(Code)
Used to determine whether to use pop3 before smtp, and if so the settings.



popHost
protected String popHost(Code)
the host name of the pop3 server



popPassword
protected String popPassword(Code)
the password to log into the pop3 server



popUsername
protected String popUsername(Code)
the user name to log into the pop3 server



replyList
protected List replyList(Code)
List of "replyTo" email adresses



sentDate
protected Date sentDate(Code)
Sent date



smtpPort
protected String smtpPort(Code)
The port number of the mail server to connect to. Defaults to the standard port ( 25 ).



subject
protected String subject(Code)
The Subject



toList
protected List toList(Code)
List of "to" email adresses





Method Detail
addBcc
public Email addBcc(String email) throws EmailException(Code)
Add a blind BCC recipient to the email.
Parameters:
  email - A String. An Email.
throws:
  EmailException - Indicates an invalid email address
since:
   1.0



addBcc
public Email addBcc(String email, String name) throws EmailException(Code)
Add a blind BCC recipient to the email.
Parameters:
  email - A String.
Parameters:
  name - A String. An Email.
throws:
  EmailException - Indicates an invalid email address
since:
   1.0



addCc
public Email addCc(String email) throws EmailException(Code)
Add a recipient CC to the email.
Parameters:
  email - A String. An Email.
throws:
  EmailException - Indicates an invalid email address.
since:
   1.0



addCc
public Email addCc(String email, String name) throws EmailException(Code)
Add a recipient CC to the email.
Parameters:
  email - A String.
Parameters:
  name - A String.
throws:
  EmailException - Indicates an invalid email address. An Email.
since:
   1.0



addHeader
public void addHeader(String name, String value)(Code)
Adds a header ( name, value ) to the headers Map.
Parameters:
  name - A String with the name.
Parameters:
  value - A String with the value.
since:
   1.0



addReplyTo
public Email addReplyTo(String email) throws EmailException(Code)
Add a reply to address to the email.
Parameters:
  email - A String. An Email.
throws:
  EmailException - Indicates an invalid email address
since:
   1.0



addReplyTo
public Email addReplyTo(String email, String name) throws EmailException(Code)
Add a reply to address to the email.
Parameters:
  email - A String.
Parameters:
  name - A String. An Email.
throws:
  EmailException - Indicates an invalid email address
since:
   1.0



addTo
public Email addTo(String email) throws EmailException(Code)
Add a recipient TO to the email.
Parameters:
  email - A String.
throws:
  EmailException - Indicates an invalid email address. An Email.
since:
   1.0



addTo
public Email addTo(String email, String name) throws EmailException(Code)
Add a recipient TO to the email.
Parameters:
  email - A String.
Parameters:
  name - A String.
throws:
  EmailException - Indicates an invalid email address. An Email.
since:
   1.0



buildMimeMessage
public void buildMimeMessage() throws EmailException(Code)
Build the internal MimeMessage to be sent.
throws:
  EmailException - if there was an error.
since:
   1.0



getFromAddress
public InternetAddress getFromAddress()(Code)
Gets the sender of the email. from address



getHostName
public String getHostName()(Code)
Gets the host name of the SMTP server, host name



getMailSession
public Session getMailSession() throws EmailException(Code)
Initialise a mailsession object A Session.
throws:
  EmailException - thrown when host name was not set.
since:
   1.0



getMimeMessage
public MimeMessage getMimeMessage()(Code)
Returns the internal MimeMessage. Please not that the MimeMessage is build by the buildMimeMessage() method. the MimeMessage



getSentDate
public Date getSentDate()(Code)
Gets the sent date for the email. date to be used as the sent date for the email
since:
   1.0



getSmtpPort
public String getSmtpPort()(Code)
Gets the listening port of the SMTP server. smtp port



getSubject
public String getSubject()(Code)
Gets the subject of the email. email subject



send
public String send() throws EmailException(Code)
Sends the email. Internally we build a MimeMessage which is afterwards sent to the SMTP server. the message id of the underlying MimeMessage
throws:
  EmailException - the sending failed



sendMimeMessage
public String sendMimeMessage() throws EmailException(Code)
Sends the previously created MimeMessage to the SMTP server. the message id of the underlying MimeMessage
throws:
  EmailException - the sending failed



setAuthentication
public void setAuthentication(String userName, String password)(Code)
Sets the userName and password if authentication is needed. If this method is not used, no authentication will be performed.

This method will create a new instance of DefaultAuthenticator using the supplied parameters.
Parameters:
  userName - User name for the SMTP server
Parameters:
  password - password for the SMTP server
See Also:   DefaultAuthenticator
See Also:   Email.setAuthenticator
since:
   1.0




setAuthenticator
public void setAuthenticator(Authenticator newAuthenticator)(Code)
Sets the Authenticator to be used when authentication is requested from the mail server.

This method should be used when your outgoing mail server requires authentication. Your mail server must also support RFC2554.
Parameters:
  newAuthenticator - the Authenticator object.
See Also:   Authenticator
since:
   1.0




setBcc
public Email setBcc(Collection aCollection) throws EmailException(Code)
Set a list of "BCC" addresses
Parameters:
  aCollection - collection of InternetAddress objects An Email.
throws:
  EmailException - Indicates an invalid email address
since:
   1.0



setBounceAddress
public Email setBounceAddress(String email)(Code)
Set the "bounce address" - the address to which undeliverable messages will be returned. If this value is never set, then the message will be sent to the address specified with the System property "mail.smtp.from", or if that value is not set, then to the "from" address.
Parameters:
  email - A String. An Email.
since:
   1.0



setCc
public Email setCc(Collection aCollection) throws EmailException(Code)
Set a list of "CC" addresses.
Parameters:
  aCollection - collection of InternetAddress objects. An Email.
throws:
  EmailException - Indicates an invalid email address
since:
   1.0.



setCharset
public void setCharset(String newCharset)(Code)
Set the charset of the message.
Parameters:
  newCharset - A String.
since:
   1.0



setContent
public void setContent(MimeMultipart aMimeMultipart)(Code)
Set the emailBody to a MimeMultiPart
Parameters:
  aMimeMultipart - aMimeMultipart
since:
   1.0



setContent
public void setContent(Object aObject, String aContentType)(Code)
Set the content & contentType
Parameters:
  aObject - aObject
Parameters:
  aContentType - aContentType
since:
   1.0



setDebug
public void setDebug(boolean d)(Code)
Setting to true will enable the display of debug information.
Parameters:
  d - A boolean.
since:
   1.0



setFrom
public Email setFrom(String email) throws EmailException(Code)
Set the FROM field of the email.
Parameters:
  email - A String. An Email.
throws:
  EmailException - Indicates an invalid email address.
since:
   1.0



setFrom
public Email setFrom(String email, String name) throws EmailException(Code)
Set the FROM field of the email.
Parameters:
  email - A String.
Parameters:
  name - A String.
throws:
  EmailException - Indicates an invalid email address. An Email.
since:
   1.0



setHeaders
public void setHeaders(Map map)(Code)
Used to specify the mail headers. Example: X-Mailer: Sendmail, X-Priority: 1( highest ) or 2( high ) 3( normal ) 4( low ) and 5( lowest ) Disposition-Notification-To: user@domain.net
Parameters:
  map - A Map.
since:
   1.0



setHostName
public void setHostName(String aHostName)(Code)
Set the hostname of the outgoing mail server
Parameters:
  aHostName - aHostName
since:
   1.0



setMailSession
public void setMailSession(Session aSession)(Code)
Supply a mail Session object to use
Parameters:
  aSession - mail session to be used
since:
   1.0



setMsg
abstract public Email setMsg(String msg) throws EmailException(Code)
Define the content of the mail. It should be overidden by the subclasses.
Parameters:
  msg - A String. An Email.
throws:
  EmailException - generic exception.
since:
   1.0



setPopBeforeSmtp
public void setPopBeforeSmtp(boolean newPopBeforeSmtp, String newPopHost, String newPopUsername, String newPopPassword)(Code)
Set details regarding "pop3 before smtp" authentication.
Parameters:
  newPopBeforeSmtp - Wether or not to log into pop3server before sending mail.
Parameters:
  newPopHost - The pop3 host to use.
Parameters:
  newPopUsername - The pop3 username.
Parameters:
  newPopPassword - The pop3 password.
since:
   1.0



setSentDate
public void setSentDate(Date date)(Code)
Sets the sent date for the email. The sent date will default to the current date if not explictly set.
Parameters:
  date - Date to use as the sent date on the email
since:
   1.0



setSmtpPort
public void setSmtpPort(int aPortNumber)(Code)
Set the port number of the outgoing mail server.
Parameters:
  aPortNumber - aPortNumber
since:
   1.0



setSubject
public Email setSubject(String aSubject)(Code)
Set the email subject.
Parameters:
  aSubject - A String. An Email.
since:
   1.0



setTo
public Email setTo(Collection aCollection) throws EmailException(Code)
Set a list of "TO" addresses.
Parameters:
  aCollection - collection of InternetAddress objects.
throws:
  EmailException - Indicates an invalid email address. An Email.
since:
   1.0



toInternetAddressArray
protected InternetAddress[] toInternetAddressArray(List list)(Code)
Utility to copy List of known InternetAddress objects into an array.
Parameters:
  list - A List. An InternetAddress[].
since:
   1.0



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.