com.groiss.util
Class MailSender

java.lang.Object
  extended by com.groiss.util.MailSender

public class MailSender
extends java.lang.Object

Use the methods in this class for sending SMTP mails.


Constructor Summary
MailSender()
           
 
Method Summary
static java.lang.String getSMTPHost()
           
static boolean send(java.lang.String[] to, java.lang.String[] cc, java.lang.String[] bcc, java.lang.String from, java.lang.String host, java.lang.String subject, java.lang.String msgText, java.lang.Object[] parts, java.lang.String[] fileNames)
          Method for sending mails with attachments
static boolean send(java.lang.String[] to, java.lang.String[] cc, java.lang.String[] bcc, java.lang.String from, java.lang.String host, java.lang.String subject, java.lang.String msgText, java.lang.String contentType, java.lang.Object[] parts, java.lang.String[] fileNames)
           
static boolean send(java.lang.String[] to, java.lang.String[] cc, java.lang.String[] bcc, java.lang.String from, java.lang.String host, java.lang.String subject, java.lang.String msgText, java.lang.String charset, java.lang.String contentType, java.lang.Object[] parts, java.lang.String[] fileNames)
           
static boolean send(java.lang.String[] to, java.lang.String from, java.lang.String host, java.lang.String subject, java.lang.String msgText, java.lang.String contentType)
          Method for sending mails without attachments.
static boolean send(java.lang.String[] to, java.lang.String from, java.lang.String host, java.lang.String subject, java.lang.String msgText, java.lang.String[] files)
          Method for sending mails with attachments
static boolean send(java.lang.String to, java.lang.String from, java.lang.String host, java.lang.String subject, java.lang.String msgText)
          Method for sending mails without attachments.
static boolean send(java.lang.String to, java.lang.String from, java.lang.String host, java.lang.String subject, java.lang.String msgText, java.lang.String contentType)
          Method for sending mails without attachments.
static void sendToAdmin(java.lang.String message)
          Send a message to the system administrator.
static void sendToAdmin(java.lang.String subject, java.lang.String message)
          Send a message to the system administrator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MailSender

public MailSender()
Method Detail

send

public static boolean send(java.lang.String to,
                           java.lang.String from,
                           java.lang.String host,
                           java.lang.String subject,
                           java.lang.String msgText)
Method for sending mails without attachments.

Parameters:
to - the recipient
from - the sender
host - the mailer host
subject - the subject text
msgText - the message text
Returns:
true on success

send

public static boolean send(java.lang.String to,
                           java.lang.String from,
                           java.lang.String host,
                           java.lang.String subject,
                           java.lang.String msgText,
                           java.lang.String contentType)
Method for sending mails without attachments.

Parameters:
to - the recipient
from - the sender
host - the mailer host
subject - the subject text
msgText - the message text
contentType - the mime-type
Returns:
true on success

send

public static boolean send(java.lang.String[] to,
                           java.lang.String from,
                           java.lang.String host,
                           java.lang.String subject,
                           java.lang.String msgText,
                           java.lang.String contentType)
Method for sending mails without attachments.

Parameters:
to - the recipients
from - the sender
host - the mailer host
subject - the subject text
msgText - the message text
contentType - the mime-type
Returns:
true on success

send

public static boolean send(java.lang.String[] to,
                           java.lang.String from,
                           java.lang.String host,
                           java.lang.String subject,
                           java.lang.String msgText,
                           java.lang.String[] files)
Method for sending mails with attachments

Parameters:
to - the recipient
from - the sender
host - the mailer host
subject - the subject text
msgText - the message text
files - the attached files (path names). These files will be attached with their real filenames.
Returns:
true on success

send

public static boolean send(java.lang.String[] to,
                           java.lang.String[] cc,
                           java.lang.String[] bcc,
                           java.lang.String from,
                           java.lang.String host,
                           java.lang.String subject,
                           java.lang.String msgText,
                           java.lang.Object[] parts,
                           java.lang.String[] fileNames)
Method for sending mails with attachments

Parameters:
to - the recipient(s)
cc - the cc recipient(s)
bcc - the bcc recipient(s)
from - the sender
host - the mailer host
subject - the subject text
msgText - the message text
parts - the attached mime body parts or files (path names leading to the files, thus, a String[]). If the parameter contains paths to files, you can use the next parameter fileNames to give names to the files.
fileNames - if parts contains files, then you can provide filenames in this array. Ensure that it has a name for every file listed in the parts array. The first element of the parts array will be given the first name from the fileNames array. If you set fileNames to null, the real file names of the files will be used.
Returns:
true on success

send

public static boolean send(java.lang.String[] to,
                           java.lang.String[] cc,
                           java.lang.String[] bcc,
                           java.lang.String from,
                           java.lang.String host,
                           java.lang.String subject,
                           java.lang.String msgText,
                           java.lang.String contentType,
                           java.lang.Object[] parts,
                           java.lang.String[] fileNames)

send

public static boolean send(java.lang.String[] to,
                           java.lang.String[] cc,
                           java.lang.String[] bcc,
                           java.lang.String from,
                           java.lang.String host,
                           java.lang.String subject,
                           java.lang.String msgText,
                           java.lang.String charset,
                           java.lang.String contentType,
                           java.lang.Object[] parts,
                           java.lang.String[] fileNames)

sendToAdmin

public static void sendToAdmin(java.lang.String message)
Send a message to the system administrator. Subject is set to "@enterprise Alert from "

Parameters:
message - the message

sendToAdmin

public static void sendToAdmin(java.lang.String subject,
                               java.lang.String message)
Send a message to the system administrator.

Parameters:
subject - the subject
message - the message

getSMTPHost

public static java.lang.String getSMTPHost()


@enterprise 8.0.22989 Copyright © 2001-2017 Groiss Informatics GmbH. All Rights Reserved.