jasp.jmail
Class SMTPMail

java.lang.Object
  extended byjasp.jmail.SMTPMail

public class SMTPMail
extends java.lang.Object

Implements jMail.SMTPMAIL in java


Constructor Summary
SMTPMail()
           
 
Method Summary
 void AddAttachment(java.lang.String filename)
          Adds a file attachment to the mssage
 void AddAttachment(java.lang.String filename, java.lang.String contenttype)
           
 void AddCustomAttachment(java.lang.String filename, java.lang.String data)
          Adds a custom attachment.
 void AddHeader(java.lang.String xheader, java.lang.String value)
          Adds a user defined X-header to the message
 void AddNativeHeader(java.lang.String header, java.lang.String value)
           
 void AddRecipient(java.lang.String email)
          Adds a recipient to the message
 void AddRecipientBCC(java.lang.String email)
          Adds a Blind Carbon Copy recipient to the message
 void AddRecipientCC(java.lang.String email)
          Adds a Carbon Copy recipient to the message
 void AddRecipientEx(java.lang.String email, java.lang.String name)
          Adds a recipient with a name to the message
 void AddURLAttachment(java.lang.String bstrURL, java.lang.String bstrAttachAs)
           
 void AddURLAttachment(java.lang.String bstrURL, java.lang.String bstrAttachAs, java.lang.String bstrAuth)
          Downloads and adds an attachment based on an URL.
 void AppendBodyFromFile(java.lang.String filename)
          Appends body text from a file
 void AppendText(java.lang.String text)
          Append "text" to body
 void ClearAttachments()
          Clears the list of attachments
 void ClearCustomHeaders()
          Cleare custom headers
 void ClearRecipients()
           
 void Close()
          Force JMail to close an cached connection to a mailserver.
 boolean Execute()
          Executes and sends the message to the server
 void ExtractEmailAddressesFromURL(java.lang.String bstrURL)
           
 void ExtractEmailAddressesFromURL(java.lang.String bstrURL, java.lang.String bstrAuth)
          Downloads and adds email addresses from an URL.
 java.lang.String getBody()
          The body of the message.
 java.lang.String getCharset()
           
 java.lang.String getContentTransferEncoding()
           
 java.lang.String getContentType()
           
 int getErrorCode()
          Contains the error code if JMail.silent is set to true
 java.lang.String getErrorMessage()
          Contains the error message if JMail.silent is set to true
 java.lang.String getLog()
          This is the log created by JMail when loging is set to true
 void GetMessageBodyFromURL(java.lang.String bstrURL)
           
 void GetMessageBodyFromURL(java.lang.String bstrURL, java.lang.String bstrAuth)
          Clears the body of the message and replaces it with the contents of the URL.
 java.lang.String getMimeVersion()
           
 boolean getPipelining()
           
 int getPriority()
           
 java.lang.String getRecipients()
          Readonly property of all recipients of this message
 java.lang.String getReplyTo()
           
 java.lang.String getSender()
           
 java.lang.String getSenderName()
           
 java.lang.String getServerAddress()
           
 boolean getSilent()
           
 boolean getSimpleLayout()
           
 java.lang.String getSubject()
          Specifies the subject of the message
 void LogCustomMessage(java.lang.String message)
          Logs a custom user message to the JMail log.
 void setBody(java.lang.String body)
           
 void setCharset(java.lang.String chars)
          This is the charset of the message.
 void setContentTransferEncoding(java.lang.String cte)
           
 void setContentType(java.lang.String str)
          This is the contentype of the message.
 void setDeferredDelivery(vbdate vd)
          DeferredDelivery : Date Sets defered delivery of messages.
 void setEncoding(java.lang.String e)
          This can be used to change the default Attachment encoding from base64.
 void setISOEncodeHeaders(boolean b)
          Encodes header stings according to iso-8859-1 character sets.
 void setLazySend(boolean b)
          This property specifies if JMail is to wait until the mail is sent and then return or if it is to buffer the message and send it in the background.
 void setLogging(boolean b)
          Enables/Disables logging in JMail
 void setMailDomain(java.lang.String str)
          This can be used to override the EHLO/HELO statement to your mailserver
 void setMailServerName(java.lang.String user)
          Used to specify the username for SMTP server authentication if the mail server requires a user to login.
 void setMailServerPassword(java.lang.String mp)
          Used to specify the password for SMTP server authentication if the mail server requires a user to login.
 void setMimeVersion(java.lang.String v)
          Specifies the mime version.
 void setPipelining(boolean b)
          Overrides if JMail should use pipelining on a server that supports it.
 void setPriority(int i)
          This is the priority of the message.
 void setReplyTo(java.lang.String to)
          Specifies a optional reply address
 void setReturnReceipt(boolean b)
          Specifies wether or not the sender requires a return receipt.
 void setSender(java.lang.String send)
           
 void setSenderName(java.lang.String send)
           
 void setServerAddress(java.lang.String add)
          Specifies the address of the server.
 void setSilent(boolean b)
          Set to true, JMail will not trow exceptions.
 void setSimpleLayout(boolean b)
          Set to true to reduce the number of headers JMail produces.
 void setSubject(java.lang.String s)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SMTPMail

public SMTPMail()
Method Detail

getBody

public java.lang.String getBody()
The body of the message. To append text to the body use AppendText


setBody

public void setBody(java.lang.String body)

setCharset

public void setCharset(java.lang.String chars)
This is the charset of the message. The default is "US-ASCII"


getCharset

public java.lang.String getCharset()

setContentTransferEncoding

public void setContentTransferEncoding(java.lang.String cte)

getContentTransferEncoding

public java.lang.String getContentTransferEncoding()

setContentType

public void setContentType(java.lang.String str)
This is the contentype of the message. It defaults to "text/plain" but can be set to whatever you need. If you want to send HTML in your messages, change this to "text/html"


getContentType

public java.lang.String getContentType()

setDeferredDelivery

public void setDeferredDelivery(vbdate vd)
DeferredDelivery : Date Sets defered delivery of messages. If the mailserver supports it the message wont be delivered before this date and time.


setEncoding

public void setEncoding(java.lang.String e)
This can be used to change the default Attachment encoding from base64. Valid options are "base64", "uuencode" or "quoted-printable" JMail.Encoding = "base64"


getErrorCode

public int getErrorCode()
Contains the error code if JMail.silent is set to true


getErrorMessage

public java.lang.String getErrorMessage()
Contains the error message if JMail.silent is set to true


setISOEncodeHeaders

public void setISOEncodeHeaders(boolean b)
Encodes header stings according to iso-8859-1 character sets. The default is true.


setLazySend

public void setLazySend(boolean b)
This property specifies if JMail is to wait until the mail is sent and then return or if it is to buffer the message and send it in the background. By setting this you do however don get controll of error messages etc.

NOTE: If you use this option, ServerAddress have NO function. The lazysend function will resolve the Mailserver with DNS queries. This can be a problem in some configurations.


getLog

public java.lang.String getLog()
This is the log created by JMail when loging is set to true


setLogging

public void setLogging(boolean b)
Enables/Disables logging in JMail


setMailDomain

public void setMailDomain(java.lang.String str)
This can be used to override the EHLO/HELO statement to your mailserver


setMimeVersion

public void setMimeVersion(java.lang.String v)
Specifies the mime version. The default is "1.0"


getMimeVersion

public java.lang.String getMimeVersion()

setPriority

public void setPriority(int i)
This is the priority of the message. The range of priorities can be from 1 to 5.
  1. This means that the message is High Priority. Some mailers prefer to call this level "Urgent".
  2. This is also high priority.
  3. This is normal priority.
  4. This is low priority.
  5. This is the lowest priority.


getPriority

public int getPriority()

getRecipients

public java.lang.String getRecipients()
Readonly property of all recipients of this message


setReplyTo

public void setReplyTo(java.lang.String to)
Specifies a optional reply address


getReplyTo

public java.lang.String getReplyTo()

setReturnReceipt

public void setReturnReceipt(boolean b)
Specifies wether or not the sender requires a return receipt. The default value of the property is "false"


setSender

public void setSender(java.lang.String send)

getSender

public java.lang.String getSender()

setSenderName

public void setSenderName(java.lang.String send)

getSenderName

public java.lang.String getSenderName()

setServerAddress

public void setServerAddress(java.lang.String add)
Specifies the address of the server. There can be more than one server specified by separating the list with a semicolon. If a port other than 25 is used then specify this by adding a colon after the servername. If the serverAddress is left blank JMail will try to resolv the remote Mail server and sen the message directly to that server.


getServerAddress

public java.lang.String getServerAddress()

setSilent

public void setSilent(boolean b)
Set to true, JMail will not trow exceptions. Instead JMail.execute() will return true or false depending on the success of the operation


getSilent

public boolean getSilent()

setSimpleLayout

public void setSimpleLayout(boolean b)
Set to true to reduce the number of headers JMail produces.


getSimpleLayout

public boolean getSimpleLayout()

getSubject

public java.lang.String getSubject()
Specifies the subject of the message


setSubject

public void setSubject(java.lang.String s)

setPipelining

public void setPipelining(boolean b)
Overrides if JMail should use pipelining on a server that supports it.


getPipelining

public boolean getPipelining()

AddAttachment

public void AddAttachment(java.lang.String filename)
                   throws java.lang.Exception
Adds a file attachment to the mssage

Throws:
java.lang.Exception

AddAttachment

public void AddAttachment(java.lang.String filename,
                          java.lang.String contenttype)
                   throws java.lang.Exception
Throws:
java.lang.Exception

AddCustomAttachment

public void AddCustomAttachment(java.lang.String filename,
                                java.lang.String data)
                         throws java.lang.Exception
Adds a custom attachment. This can be used to attach "virtual files" like a generated text string or certificate etc.

Throws:
java.lang.Exception

AddHeader

public void AddHeader(java.lang.String xheader,
                      java.lang.String value)
Adds a user defined X-header to the message


AddNativeHeader

public void AddNativeHeader(java.lang.String header,
                            java.lang.String value)

AddRecipient

public void AddRecipient(java.lang.String email)
Adds a recipient to the message


AddRecipientBCC

public void AddRecipientBCC(java.lang.String email)
                     throws java.lang.Exception
Adds a Blind Carbon Copy recipient to the message

Throws:
java.lang.Exception

AddRecipientCC

public void AddRecipientCC(java.lang.String email)
                    throws java.lang.Exception
Adds a Carbon Copy recipient to the message

Throws:
java.lang.Exception

AddRecipientEx

public void AddRecipientEx(java.lang.String email,
                           java.lang.String name)
Adds a recipient with a name to the message


AddURLAttachment

public void AddURLAttachment(java.lang.String bstrURL,
                             java.lang.String bstrAttachAs,
                             java.lang.String bstrAuth)
                      throws java.lang.Exception
Downloads and adds an attachment based on an URL. A seconds argument, "AttachAs", is used for specifying the filename that the attachment will receive in the message. A third and optional argument is used for optional WWW-Authentication.

Throws:
java.lang.Exception

AddURLAttachment

public void AddURLAttachment(java.lang.String bstrURL,
                             java.lang.String bstrAttachAs)
                      throws java.lang.Exception
Throws:
java.lang.Exception

AppendBodyFromFile

public void AppendBodyFromFile(java.lang.String filename)
Appends body text from a file


AppendText

public void AppendText(java.lang.String text)
Append "text" to body


ClearAttachments

public void ClearAttachments()
Clears the list of attachments


ClearCustomHeaders

public void ClearCustomHeaders()
Cleare custom headers


ClearRecipients

public void ClearRecipients()

setMailServerPassword

public void setMailServerPassword(java.lang.String mp)
Used to specify the password for SMTP server authentication if the mail server requires a user to login.


setMailServerName

public void setMailServerName(java.lang.String user)
Used to specify the username for SMTP server authentication if the mail server requires a user to login.


Close

public void Close()
Force JMail to close an cached connection to a mailserver.


Execute

public boolean Execute()
Executes and sends the message to the server


ExtractEmailAddressesFromURL

public void ExtractEmailAddressesFromURL(java.lang.String bstrURL,
                                         java.lang.String bstrAuth)
Downloads and adds email addresses from an URL.


ExtractEmailAddressesFromURL

public void ExtractEmailAddressesFromURL(java.lang.String bstrURL)

GetMessageBodyFromURL

public void GetMessageBodyFromURL(java.lang.String bstrURL,
                                  java.lang.String bstrAuth)
Clears the body of the message and replaces it with the contents of the URL. The contenttype is automaticly set to match the contentype of the URL. The second argument (login and password) is optional.


GetMessageBodyFromURL

public void GetMessageBodyFromURL(java.lang.String bstrURL)

LogCustomMessage

public void LogCustomMessage(java.lang.String message)
Logs a custom user message to the JMail log. This function works ONLY if loging is set to true.